python 2.7 - Django forms adding class attribute from the constructor -


as can see in code sample below, i'm trying add multiple choice field constructor (instead of doing in commented line) doesn't seem work, doesn't matter if it's before or after call of super().

any advices on how can add attribute constructor?

class pageform(forms.form):     # answers = forms.modelmultiplechoicefield(answer.objects.all())      def __init__(self, *args, **kwargs):          self.answers = forms.modelmultiplechoicefield(answer.objects.all())          super(forms.form, self).__init__(*args, **kwargs)          self.answers = forms.modelmultiplechoicefield(answer.objects.all()) 

p.s. know might irrelevant example, need thing more complex thing :d

fields need added after super. instead self.answers, try self.fields['answers']


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -