Fail to create Django registration form with email and password only

112 views
Skip to first unread message

Yan Cheng Cheok

unread,
Aug 19, 2018, 6:15:44 PM8/19/18
to Django users

Creating basic registration/ authentication in Django is insanely hard.


After many tries, I manage to create basic registration/ authentication in Django using username and password.


enter image description here

The code is shown in https://github.com/yccheok/django


Now, I wish to create registration form which only use email and password. No username.


I try to following the official example https://docs.djangoproject.com/en/dev/topics/auth/customizing/#a-full-example . The example is using email, password and DOB for registration. I'm not interested in DOB, but I will just simply follow the example at this point.


I made the following changes : https://github.com/yccheok/django/commit/ae0b16d38a39fad78a2137e2649c0f3fda12a3ff


However, I'm facing 2 problems.

  1. The registration form, still look the same as previous registration form. It has username and password text fields. What I'm expecting are email and password text fields.
  2. Error Manager isn't available; 'auth.User' has been swapped for 'accounts.MyUser' after clicking Sign up button. I had read Manager isn't available; 'auth.User' has been swapped for 'polls.User' , but total clueless on how to apply the solution in my case.

enter image description here



There's one thing confusing me.

Why in accounts/admin.py, we are using from accounts.models import MyUser. But in web/settings.py, we are using AUTH_USER_MODEL = 'accounts.MyUser' (Instead of AUTH_USER_MODEL = 'accounts.models.MyUser')



Any idea how I can modify my basic workable registration/login example (https://github.com/yccheok/django), to make them register using email and password?

Mikhailo Keda

unread,
Aug 20, 2018, 3:04:46 AM8/20/18
to Django users
No need to change Django registration/authentication, you need to use it.

Check this example - https://chat.mkeda.me/login?next=/
source code for registration/authentication - https://bitbucket.org/voron-raven/chat/src/f78b6531652f866109dbfa2f8aeffac6c0f1bb32/core/views.py#lines-247:283
Just set username same as email.
Reply all
Reply to author
Forward
0 new messages