Creating the Best TODO app With the Django Master [pt.1]

Creating the Best TODO app With the Django Master [pt.1]

This will be a Multipart Blog, this part we will be looking at the M of MVT architecture which is Models.

I will dominate Django Very Hard with No Mercy. In this Blog we are going to create a Database to store our Todo tasks in and perform CRUD operations in that data with the help of Django's default Admin Panel

  1. Create virtual environment.

  2. Activate the virtual environment.

  3. Install Django in the environment.

  4. Create a Django Project named Todo.

  5. run the Django server

  6. Create an app named home & add home to the installed apps list in

     django-admin startapp home
  7. Create the Model (database) for the Task

     from django.db import models
     # Create your models here.
     class Task(models.Model):
         title = models.CharField(max_length=200)
         complete = models.BooleanField(default=False)
         created = models.DateTimeField(auto_now_add=True)
         expires = models.DateTimeField(auto_now_add=False,blank=True,null=True)
         def __str__(self):
             return self.title
         def is_complete(self):
             return self.complete
  8. Add the Model in the Admin Panel by adding it to the file

     from django.contrib import admin
     from .models import Task
     # Register your models here.

  9. Make migrations, migrate and Create superuser

     py makemigrations
     py migrate
     py createsuperuser
  10. Run the Server and go to admin panel.

  11. py runserver 
    goto https://localhost:8000/admin
  12. login to admin panel and you should see the Tasks under the Home section. Click on Tasks and do CRUD operations.

Congratulations! You've successfully created the database for The Best Todo app ever.

You've completed 2/900 steps of becoming a Django Master

In next Blog, we'll be looking at the V part of MVT architecture

Did you find this article valuable?

Support Nischal lamichhane by becoming a sponsor. Any amount is appreciated!