So, I have a form like this:
<tt>
class AddUserForm(forms.Form):
username = forms.CharField(label='Username', required=False)
password1 = forms.CharField(label='Password',
widget=forms.PasswordInput)
password2 = forms.CharField(label='Password (Again)',
widget=forms.PasswordInput)
first_name = forms.CharField(label='First Name')
last_name = forms.CharField(label='Last Name')
email = forms.EmailField(label='Email')
group = forms.ModelChoiceField(label='Group',
queryset=Group.objects.all())
team = forms.ModelChoiceField(label='Team',
queryset=Team.objects.all())
def save(self):
//Some custom procedures here
return u
</tt>
And I use it in a view like so:
AddUserFormset = formset_factory(AddUserForm, extra=10, max_num=0)
<tt>
if request.method == 'POST':
formset = AddUserFormset(request.POST, request.FILES)
#If formset is valid
if formset.is_valid():
#Do some stuff with the forms
return render_to_response('profiles/
profile_add_users.html', { 'formset':formset, },
context_instance=RequestContext(request))
#Something was wrong with the formset
else:
return render_to_response('profiles/
profile_add_users.html', { 'formset':formset },
context_instance=RequestContext(request))
</tt>
For some reason, all of the fields in the forms I leave blank give me
"This field is required" errors and formset.is_valid() keeps failing.
Is there something I am missing? Isn't the formset supposed to be
smart enough to see that forms will all empty fields should be
ignored?
Any ideas
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---