# Step 01 — Application Backend Setup - geraldgsh/django-todo GitHub Wiki
Registering the Todo application
Register the todo application as an installed app so that Django can recognize it. Open the backend/settings.py file and update the INSTALLED_APPS section as so:
# backend/settings.py
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'todo' # add this
]
Defining the Todo model
Create a model to define how the Todo items should be stored in the database, open the todo/models.py file and update it with this snippet:
# todo/models.py
from django.db import models
# Create your models here.
# add this
class Todo(models.Model):
title = models.CharField(max_length=120)
description = models.TextField()
completed = models.BooleanField(default=False)
def _str_(self):
return self.title
The code snippet above describes three properties on the Todo model:
- Title
- Description
- Completed
The completed property is the status of a task; a task will either be completed or not completed at any time.
Create a migration file and apply the changes to the database:
$ python3 manage.py makemigrations todo
$ python3 manage.py migrate todo
Open the todo/admin.py file and update:
# todo/admin.py
from django.contrib import admin
from .models import Todo # add this
class TodoAdmin(admin.ModelAdmin): # add this
list_display = ('title', 'description', 'completed') # add this
# Register your models here.
admin.site.register(Todo, TodoAdmin) # add this
Start the server once more and log in on the address — http://localhost:8000/admin:
$ python3 manage.py runserver
We can create, edit and delete Todo items using this interface.