A simple Task Manager built with Django that demonstrates key features such as user authentication, task creation, editing, and deletion (CRUD operations), and the use of Django's built-in admin interface.
This project is a Django-based task manager where users can:
- Register and log in to manage their own tasks.
- Create, view, edit, and delete tasks.
- Assign priorities and deadlines to tasks.
- Mark tasks as completed or incomplete.
- Access an admin panel to manage users and tasks.
.
├── lume
│ ├── db.sqlite3 # SQLite database file
│ ├── manage.py # Django management script
│ └── tasks # Main Django app for task management
│ ├── __init__.py
│ ├── asgi.py
│ ├── forms.py # Forms used for task management
│ ├── migrations # Database migrations for the tasks app
│ ├── models.py # Task model definition
│ ├── settings.py # Project settings
│ ├── templates # HTML templates for the app
│ ├── urls.py # URL routing for the app
│ ├── views.py # Views that handle task operations
│ ├── wsgi.py
├── poetry.lock # Poetry lock file for dependencies
├── pyproject.toml # Project configuration file (for Poetry)
└── README.md # Project documentation
- Python 3.12+
- Django 5.1+
- Poetry for dependency management
- Ruff for linting and formatting
- User Authentication: Users can register, log in, and manage their own tasks.
- Task Management: Users can create, update, delete, and view tasks.
- Admin Interface: A fully functional admin interface to manage users and tasks.
First, clone this repository to your local machine:
git clone <repository_url>
cd django_exampleThis project uses Poetry to manage dependencies. If you don't have Poetry installed, you can install it by following the Poetry installation guide.
Please use this statement to have a local environment inside the project folder
poetry config virtualenvs.in-project trueOnce Poetry is installed, run the following command to install all dependencies and create a virtual environment:
poetry installActivate the Poetry environment:
poetry shellRun the following command to apply the migrations and create the SQLite database:
poetry run python lume/manage.py migrateTo access the Django admin interface, you'll need a superuser. Create one by running:
poetry run python lume/manage.py createsuperuserFollow the prompts to set up the superuser account.
Start the Django development server:
poetry run python lume/manage.py runserverOnce the server is running, you can visit the following URLs:
- Task Manager:
http://127.0.0.1:8000/tasks/ - Admin Panel:
http://127.0.0.1:8000/admin/
Visit http://127.0.0.1:8000/tasks/ to view, create, and manage tasks.
Go to http://127.0.0.1:8000/admin/ and log in with the superuser credentials you created to manage users and tasks.
Defines the Task model, which includes fields for:
title: Task title.description: Optional task description.priority: Task priority (integer).deadline: Optional deadline for the task (DateTime).completed: Whether the task is completed or not.user: Foreign key linking the task to a user.
Defines the TaskForm using Django's ModelForm to create and edit tasks.
Defines the views that handle task operations such as:
- Listing tasks (
task_list) - Creating tasks (
task_create) - Editing tasks (
task_edit) - Deleting tasks (
task_delete)
Maps URL routes to the corresponding views:
''- Lists tasks.'create/'- Creates a new task.'<int:pk>/edit/'- Edits an existing task.'<int:pk>/delete/'- Deletes a task.
Contains the HTML templates:
task_list.html: Displays the list of tasks.task_form.html: Form for creating and editing tasks.task_confirm_delete.html: Confirmation page for deleting a task.registration/login.html: Custom login template.
To run the development server tests:
poetry run python lume/manage.py testYou can add more test cases in the tests.py file.
This project uses Ruff for linting. To run Ruff on your code:
poetry run ruff check .To log in to the admin interface, use the superuser account credentials you created in the earlier steps.
- Admin Page 404: Ensure that
admin.site.urlsis included in yoururls.pyfile, and check ifdjango.contrib.adminis included inINSTALLED_APPSinsettings.py. - Database Issues: If migrations are not applied, run
poetry run python lume/manage.py migrateagain.