> def clean_username(self): > data = self.cleaned_data['username'] > try: > User.objects.get(username=data) > except User.DoesNotExist: > return > raise forms.ValidationError('The username "%s" is already > taken.' % > data)
The django docs [1] say that for the clean_<fieldname> method, "Just like the general field clean() method, above, this method should return the cleaned data, regardless of whether it changed anything or not." Since you're returning nothing, self.cleaned_data['username'] will be None when saving your user hence the "auth_user.username may not be NULL" exception. [1] http://docs.djangoproject.com/en/dev/ref/forms/validation/ hth, Nuno -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.