I am making a custom form object in django which has an overloaded __init__ method. The purpose of overloading the method is to dynamically generate drop-down boxes based on the new parameters.
For example,
class TicketForm(forms.Form):
Type = Type.GetTicketTypeField()
def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,
initial=None, label_suffix=':', empty_permitted=False, ticket=None):
if ticket:
self.__class__.State = State.GetTicketStateField(ticket.Type)
super(forms.BaseForm, self ).__init__(data=data, files=files, auto_id=auto_id,
prefix=prefix, initial=initial, label_suffix=label_suffix, empty_permitted=empty_permitted)
This solution does not work. It appears that the fields are created before the __init__ is called. I would assume this problem would be pretty common. What would be the django way of handling these classes of problems.