2
Anything at class level is executed when the class is defined, on first import. You already know how to do things at instantation time – by doing it in the __init__
method.
It’s not clear from your question what Q1
is. Is it a field? If so you can add it to self.fields
; otherwise just set it directly on self
.
def __init__(self, *args, **kwargs):
translation.activate('nl')
super(SurveyForm, self).__init__(*args, **kwargs)
self.fields['Q1'] = ...
# or
self.Q1 = ...
Source:stackexchange.com