Wednesday, 15 January 2014

python - Django - User creation with custom user model results in internal error -



python - Django - User creation with custom user model results in internal error -

ok, know silly question blocked , can't figure out do.

i have searched on google , stackoverflow did not found reply : tried :

adding custom fields users in django django - create user profile on user creation https://docs.djangoproject.com/en/1.4/topics/auth/#storing-additional-information-about-users

my model next :

class userprofile(models.model): user = models.onetoonefield(user) quota = models.integerfield(null = true) def create_user_profile(sender, instance, created, **kwargs): if created: userprofile.objects.create(user=instance) post_save.connect(create_user_profile, sender=user)

and view user registration next :

def register(request): if request.method == 'post': # if form has been submitted... form = registrationform(request.post) # form bound post info if form.is_valid(): # validation rules pass # process info in form.cleaned_data cd = form.cleaned_data #then create user user = user.objects.create_user(cd['username'],cd["email"],cd["password1"]) user.get_profil().quota = 20 user.save() homecoming httpresponseredirect('') else: form = registrationform() # unbound form homecoming render(request, 'registration_form.html', {'form': form,})

the line launch internalerror :

user = user.objects.create_user(cd['username'],cd["email"],cd["password1"])

and error :

internalerror @ /register/

current transaction aborted, commands ignored until end of transaction block

thank help

user = user.objects.create_user(username=form.cleaned_data['username'], password=form.cleaned_data['password'], email=form.cleaned_data['email']) user.is_active = true user.save()

python django django-models django-users django-managers

No comments:

Post a Comment