Welcome to Brannon's Reading Notes!

This serves as my personal page to keep and update my reading notes for Code Fellows Courses 201, 301, and 401.

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

  1. create and navigate into a dedicated directory called accounts for our code
  2. install Django
  3. make a new Django project called config
  4. make a new app accounts
  5. 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

  1. update config/settings.py (add accounts to installed apps)
  2. create a CustomUser model (in accounts/models.py)
  3. create UserCreation and UserChangeForm (accounts/forms.py)
  4. update admin ()
  5. makemigrations and migrate
  6. make templates, urls, views

source: https://learndjango.com/tutorials/django-custom-user-model