In Uncategorized

I have read about multiple ways on extending the django default user-model and logging in with email instead of username. For my particular needs I will just go over how i did things.

This was a 3 step process for me:

  1. Extend the BaseUserManager
  2. Extend and customers the User Model
  3. Configure AUTH_USER_MODEL

Source Code: Link

1 – Extend the BaseUserManager

I will decided to handle everything in the models.py file.py.  I first imported AbstractBaseUser and BaseUserManager

           “from django.contrib.auth.models import AbstractBaseUser, BaseUserManager”

Next i Created my UserManager. I followed django docs and a few other articles and according to my sources this is the bear min you need to configure everything. Code will be proved so you can just copy and paste.

2 – Extend the UserModel

3 – Configure AUTH_USER_MODEL

In order to user this in User model we need to set the path varible in django

No all you need to do is add the user model to admin.py so it shows in you admin panel and createa a superuser to test it out.

Contact Us

We're not around right now. But you can send us an email and we'll get back to you, asap.