django - no password set after successful registration

Aamu

I have created a custom User registration form, from the UserCreationForm. When I try to register, it does register successfully, and I can see a newly created user with the username and its email. But there's no password for that user.

In the admin, the password field for that user is No password set.. Please correct me where I am wrong. Thank you.

forms.py:

from album.forms import MyRegistrationForm

from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm

class MyRegistrationForm(UserCreationForm):
    email = forms.EmailField(required=True)

    class Meta:
        model = User
        fields = ('username', 'email', 'password1', 'password2',)

    def save(self, commit=True):
        user = super(UserCreationForm, self).save(commit=False)
        user.email = self.cleaned_data['email']

        if commit:
            user.save()

        return user

views.py:

def register_user(request):
    if request.method == "POST":
        form = MyRegistrationForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/accounts/register_success/')
    else:
        form = MyRegistrationForm()
    return render(request, 'register.html', {'form':form})
Alasdair

When calling save on the superclass using super, use the form MyRegistrationForm, not its superclass UserCreationForm.

user = super(MyRegistrationForm, self).save(commit=False)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

django get token and userid after successful registration

From Dev

Django how to get password after registration form is submitted?

From Dev

Redirect to home as a logged in user after successful registration

From Dev

Django registration redux registration only with email (no password)

From Dev

Django registration redux registration only with email (no password)

From Dev

Redirect to Login page after successful reset password

From Dev

Django Redirect after Successful Login

From Dev

Django custom registration: how to set a default password and use first name + last name as username

From Dev

Why does ServiceWorkerRegistration callback is not hitting after the successful registration of service worker?

From Dev

Send email after successful user registration using meteor js

From Dev

Why does ServiceWorkerRegistration callback is not hitting after the successful registration of service worker?

From Dev

NoReverseMatch: in the password reset form in Django-registration?

From Dev

Django User Registration - Password Reset via email

From Dev

How to set redirection after successful login?

From Dev

Set Map location after successful $http callback

From Dev

Authentication token not set after successful login

From Dev

django admin redirect after a successful login

From Dev

email not sending after successful registered : Django

From Dev

Django DeleteView - send mail after successful deletion

From Dev

Send email confirmation after registration django

From Dev

Redirect to previous page after registration in Django

From Dev

Django edit user profile after success registration

From Dev

Django Rest Framework not login after registration

From Dev

Removing second password input from django-registration form

From Dev

Removing second password input from django-registration form

From Dev

Django Redux Registration Incorrect Password / Username when it is correct

From Dev

Why does default authentication backend of django calls set_password after raising UserModel.DoesNotExist exception?

From Dev

Amazon Deeplens device is offline after successful registration, can't deploy project

From Dev

How to assign roles on successful registration?

Related Related

  1. 1

    django get token and userid after successful registration

  2. 2

    Django how to get password after registration form is submitted?

  3. 3

    Redirect to home as a logged in user after successful registration

  4. 4

    Django registration redux registration only with email (no password)

  5. 5

    Django registration redux registration only with email (no password)

  6. 6

    Redirect to Login page after successful reset password

  7. 7

    Django Redirect after Successful Login

  8. 8

    Django custom registration: how to set a default password and use first name + last name as username

  9. 9

    Why does ServiceWorkerRegistration callback is not hitting after the successful registration of service worker?

  10. 10

    Send email after successful user registration using meteor js

  11. 11

    Why does ServiceWorkerRegistration callback is not hitting after the successful registration of service worker?

  12. 12

    NoReverseMatch: in the password reset form in Django-registration?

  13. 13

    Django User Registration - Password Reset via email

  14. 14

    How to set redirection after successful login?

  15. 15

    Set Map location after successful $http callback

  16. 16

    Authentication token not set after successful login

  17. 17

    django admin redirect after a successful login

  18. 18

    email not sending after successful registered : Django

  19. 19

    Django DeleteView - send mail after successful deletion

  20. 20

    Send email confirmation after registration django

  21. 21

    Redirect to previous page after registration in Django

  22. 22

    Django edit user profile after success registration

  23. 23

    Django Rest Framework not login after registration

  24. 24

    Removing second password input from django-registration form

  25. 25

    Removing second password input from django-registration form

  26. 26

    Django Redux Registration Incorrect Password / Username when it is correct

  27. 27

    Why does default authentication backend of django calls set_password after raising UserModel.DoesNotExist exception?

  28. 28

    Amazon Deeplens device is offline after successful registration, can't deploy project

  29. 29

    How to assign roles on successful registration?

HotTag

Archive