How to add extra field in default user model and change login via username to email. using abstract class problem is that when I am use the abstract class the default function like, password hash, all validation etc. it's not working
1 Answer
To add an extra field to the default user model you would need to use AbstractUser.
There is an example on django docs that shows exactly how to use email instead of username to login and adding custom fields as well.
Only thing not clearly mentioned is that you would have to create an app, for example an app called 'customauth' by running
python manage.py startapp customauth Then you can just follow the tutorial within the files customauth/models.py and customauth/admin.py
You would also need to modify settings.py in your main app
INSTALLED_APPS = [ #other installed apps 'customauth', #add customauth to the installed apps ] and you would need to migrate your changes after with first running
python manage.py makemigrations and then running
python manage.py migrate