Reputation: 2550
I'm dynamically creating a form based on the number of skills in the database. It's created like so:
class FilterFreelancerForm(forms.Form):
def __init__(self, *args, **kwargs):
super(FilterFreelancerForm, self).__init__(*args, **kwargs)
skills = Skill.objects.all()
for skill in skills:
self.fields['custom_%s' % skill] = forms.CheckboxSelectMultiple()
My view simply instantiates the form object like so form = FilterFreelancerForm()
and returns it to the template to be rendered with {{form}}
. This causes the AttributeError: 'CheckboxSelectMultiple' object has no attribute 'label'
.
Why is this?
Upvotes: 0
Views: 292