Reading
Custom Users in Django
Upon installation, Django comes with a built in user model that is ready to go right out of the box. However, for real world applications, creating a custom user model will give you the flexibility to create and manage your user’s accounts.
To start, create a new Django project from the command line. We need to do several things:
Getting Started
- create and navigate into a dedicated directory called accounts for our code
- install Django
- make a new Django project called config
- make a new app accounts
- start the local web server
Here are the commands:
$ cd ~/Desktop
$ mkdir accounts && cd accounts
$ pipenv install django~=3.1.0
$ pipenv shell
(accounts) $ django-admin.py startproject config .
(accounts) $ python manage.py startapp accounts
(accounts) $ python manage.py runserver
Note: do not run migrate until after the custom user model is created.
Creating the Model
- update config/settings.py (add accounts to installed apps)
- create a CustomUser model (in accounts/models.py)
- create UserCreation and UserChangeForm (accounts/forms.py)
- update admin ()
- makemigrations and migrate
- make templates, urls, views
source: https://learndjango.com/tutorials/django-custom-user-model