Skip to content

A basic to-do app built with the Django framework.

Notifications You must be signed in to change notification settings

lealre/todo-django

Repository files navigation

"Hello World" with Django – A To-Do App

This repository contains a basic to-do app built with the Django framework. It features a simple interface to add, edit, and delete to-dos. In the trash area, you can either restore a to-do or permanently delete it.

Below is a quick demonstration of the app in action.

Description of GIF

To perform operations, the user must be authenticated by registering and logging into the application.

Description of GIF

Among the many features of Django, this project uses:

It uses function-based views and includes some JavaScript to enable frontend interactions.

Although it does not test every aspect of the application, it achieves 100% coverage using pytest-cov. The tests also utilize pytest.

It’s possible to run this app using Docker Compose, which automatically creates a superuser and uses a local PostgreSQL database. The PostgreSQL database is also set up within Docker Compose.

How to run this project

All the steps here were intended to a bash terminal.

This section shows how to run the project both with Docker or locally. Regardless of the method, start with the following steps:

1 - Clone the repo locally:

git clone https://github.com/lealre/todo-django.git

2 - Access the project directory:

cd todo-django

Docker Environment

How to install Docker Compose

3 - Create the .env file:

mv .env-example .env

By using the variables from .env-example, it will connect to the PostgreSQL database that was also created with Docker.

4 - Build and start the container:

docker compose up --build -d

In case you encounter a permission error for entrypoint.sh, run:

chmod +x entrypoint.sh

Access the application at http://localhost:8000/

Local Environment

The project setup uses pyenv and poetry.

After completing steps 1 and 2:

3 - Create the .env file:

mv .env-example .env

In the local environment, SQLite3 is used by default, so it's necessary to set LOCAL in the .env file:

LOCAL=1

4 - Set the Python version with pyenv:

pyenv local 3.12.2

5 - Create the virtual environment:

poetry env use 3.12.2

6 - Activate the virtual environment:

poetry shell

7 - Install dependencies:

poetry install --no-root

8 - Run the migrations:

python manage.py migrate

9 - Run the server:

python manage.py runserver

Access the application at http://localhost:8000/

To run the tests, use the following command:

task test

By default, it will run the command below before executing the tests. This command applies the Ruff linter configured in pyproject.toml:

task lint

To run the formatter, use:

task format