Trying to add custom validation for a customer creation form, but when
I add:
def clean_username(self):
try:
user =
User.objects.get(username__exact=self.cleaned_data['username'])
except User.DoesNotExist:
return self.cleaned_data['username']
raise forms.ValidationError(_('This username is already taken.'))
to check if non/existant, it suppresses the 'required_field' errors,
ie: no errors are shown when you put whatever value in the username
field (required).
It works the other way around, meaning if you leave it empty (it shows
the 'required_field' error).
Although I've read that cleaned_data, is not available if the form
isn't valid. In that case, when some fields are left empty, I suppose
it's invalid, but I can't figure out another way of doing this.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---