Django Best Practices: Custom User Model
In real world most likely we will have to create customized user models instead of use th Django’s built-in models.
set up
- set virtual environment venv.
- Install Django
- make a Django project
- create an Django app
- test runserver
Custom user model
- update settings.py
- create a
CustomUser
model - create new
UserCreation
andUserChangeForm
- update the admin
Create superuser
used to log in/out admin.
Templates/Views/URLs
- updating settings.py to create a project-level templates directory.
- create .html in templates folder
- url.py: creates paths.
- test server
read source code of DjangoX project.
substitute a custom user model
https://docs.djangoproject.com/en/3.0/topics/auth/customizing/#auth-custom-user
Things I want to know more:
- Just curious, Youtube is Django built-up, how its user model looks like? and how can I locate its source code?