This project is a simple Todo application using Django, Docker and containerized PostgreSQL.
- python3
- Django
- Docker
- Docker Compose
- Clone the repository:
git clone <repository-url>
cd django_todo
- Change default credentials for PostgreSQL
Credentials in docker-compose.yml and settings.py under DATABASES should be changed and should match.
- Build and run the Docker containers:
docker-compose up --build -d
- Populate database and create superuser
Find web container
docker ps
Then perform the commands below.
docker exec -it <container_name_or_id> python manage.py makemigrations
docker exec -it <container_name_or_id> python manage.py migrate
docker exec -it <container_name_or_id> python manage.py createsuperuser
WARNING!!!
PostgreSql saves data under docker volume postgres-data, If you remove it the above commands needs to be redone.
- Create users
Access the admin at http://localhost:8000/admin
Go to the "Users" section and click "Add User". Fill in the required fields and permissions as needed, then save the new user
-
Access the application at
http://localhost:8000
. -
Log in as one of the created users
-
Start creating TODOs
-
Shut down the webservice
docker-compose down
Warning!
The development will use a local sqlite database but the containarized version will use PostgreSQL.
If you want to use PostgresSQL during development change to
DATABASES = DATABASES_POSTGRES
in settings.py
Remember to change the database settings at settings.py#L84 to the one you used when installing your local PostgreSQL
Clone the repository
git clone <repository-url>
Switch to folder where code have been cloned, default above is django_todo
cd django_todo
Install requirements
pip install -r requirements.txt
or
python3 -m pip install -r requirements.txt
Switch to app project folder
cd todo_app
The app name is todos and its code located under todos folder.
Run tests as below while you are in the project folder todo_app
python3 manage.py test todos.tests