On Wednesday, 28 March 2012 20:31:09 UTC+1, laurence Turpin wrote: > > I'm getting the following error with my registration section of my > program. > > IntegrityError at /register/ > auth_user.username may not be NULL > > I am using django 1.3.1 and python 2.7.2 and I'm using sqlite3 as the > database. > I am a newbie and I'm learning Djanogo from the book "Learning website > development with Django" > > The registration form is displayed ok and I'm able to fill it out and > it is when I click register that the problem occurs. > > /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// > > > > My views.py looks like the following and register_page is the > relevant function here: > > <snip> >
> def clean_username(self): > username = self.cleaned_data['username'] > if not re.search(r'^\w+$', username): > raise forms.ValidationError('Username can only contain > alphanumeric characters and underscores') > try: > User.objects.get(username=username) > except ObjectDoesNotExist: > return username > raise forms.ValidationError('Username already taken. ') > Looks like you have an indentation problem in clean_username - the lines under the first "raise forms.ValidationError" should be one level to the left, otherwise they will never be reached and the method will never return the cleaned value for username. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/sXr3JbbnrqcJ. To post to this group, send email to django-users@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.