shabda
shabda

Reputation: 1758

Always prefix a Django form

I know about the prefix argument we can pass while instantiating the form. My requirements are slightly different.

I have two forms like this

class TwitterForm(forms.Form):
    friends = forms.Charfield(...)

class FBForm(forms.Form):
    friends = forms.Charfield(...)

They will always be present together, which means I can guarantee that I will need to prefix them. Is there a way to add a prefix at class level rather than at the object creation time.

Upvotes: 0

Views: 151

Answers (1)

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 799520

Override __init__() and add the keyword argument before calling the parent's method.

Upvotes: 1

Related Questions