error: IntegrityError at /accounts/register/ accounts_playersprofile.first_name may not be NULL Request Method: POST Request URL: http://localhost:8000/accounts/register/ Exception Type: IntegrityError Exception Value: accounts_playersprofile.first_name may not be NULL Exception Location: C:\Python25\lib\site-packages\django\db\backends \sqlite3\base.py in execute, line 93
views.py def register_page(request): """Register page""" if request.user.is_authenticated(): return render_to_response('register.html', {'has_account':True}) if request.POST: form = RegistrationForm(request.POST) if form.is_valid(): # save the user new_user = form.save(form.clean_data) # build activation key for their account activation_key = new_user.username + str(random.random()) key_expires = datetime.datetime.today() + datetime.timedelta(2) # Create and save their profile new_profile = PlayersProfile(user=new_user, activation_key=activation_key, key_expires=key_expires) new_profile.save() return render_to_response('register.html', {'created': True}) else: return render_to_response('register.html', {'form':form}) else: form = RegistrationForm() return render_to_response('register.html', {'form':form}) models.py class PlayersProfile(models.Model): user = models.ForeignKey(User, unique=True) activation_key = models.CharField(maxlength=40) key_expires = models.DateTimeField() forms.py class RegistrationForm(forms.Form): """Player registration form""" username = forms.CharField(max_length=20) password = forms.CharField(min_length=4, max_length=20, widget=forms.PasswordInput()) first_name = forms.CharField(max_length=20) last_name = forms.CharField(max_length=20) email = forms.EmailField(max_length=40) def save(self, data): u = User.objects.create_user(data['username'], data['email'], data['password']) u.is_active = False u.first_name = data['first_name'] u.last_name = data['last_name'] u.save() return u thanks in advance --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---