Hi,
I have built this class:
class FormClass(forms.Form):
def __init__(self, *args, **kwargs):
super(FormClass, self).__init__(*args, **kwargs)
# Get tags and their id
for t in Item.objects.get(pk=id).tags.values():
field_id = t['id'] # tag ID is the form's field name
self.fields[field_id] = forms.IntegerField(min_value=1, label
= t['name'])
This class generates a dynamic form, based on the tags attached to an
item.
if request.POST:
form = FormClass(request.POST)
if form.is_valid():
# save the information
else:
form = FormClass()
# render it all to a template
Upon entering (correct) data, the form validation throws error:
supposedly the fields are empty.
What am I doing wrong here?
Many thanks in advance,
Laundro
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---