This repository is used as a dummy project to demonstrate how to migrate to a custom Django user model mid-project.
The repository is split into two branches:
base
- starting point (using Django's default user model)master
- end point (using custom user model)
To learn how it's done check out the article.
-
Fork/Clone (make sure to clone the right branch).
-
Create and activate a virtual environment:
$ python3 -m venv venv && source venv/bin/activate
-
Install the requirements:
(venv)$ pip install -r requirements.txt
-
Spin up a Postgres container or use locally installed PostgreSQL:
$ docker run --name django-todo-postgres -p 5432:5432 \ -e POSTGRES_USER=django-todo -e POSTGRES_PASSWORD=complexpassword123 \ -e POSTGRES_DB=django-todo -d postgres
If you're going to use locally installed PostgreSQL, make sure to go to core/settings.py and change
DATABASES
credentials accordingly. -
Apply the migrations:
(venv)$ python manage.py migrate
-
(Optional) Fill the database with sample data:
$ (venv) python manage.py loaddata fixtures/auth.json --app auth $ (venv) python manage.py loaddata fixtures/todo.json --app todo
These two fixtures also create a superuser with the following credentials:
username: admin password: password
-
Run the server:
(venv)$ python manage.py runserver
-
Navigate to http://localhost:8000/admin/ in your favorite web browser and login.