0 votes
in Programming by (580 points)

I have the following model

from django.db import models

class Todo(models.Model):
    content = models.CharField(max_length=100)
    created_at_one: models.DateField(auto_now_add=True)
    finished_at: models.DateField(null=True)
    is_completed: models.BooleanField(default=False)
    list = models.ForeignKey(
        "TodoList", related_name="todos", on_delete=models.CASCADE)


class TodoList(models.Model):
    title: models.CharField(max_length=20)
    created_at: models.DateField(auto_now_add=True)

Then when I run python manage.py makemigrations and python3 manage.py migrate, there is no error. But when I check the tables created, some columns are missing.

I run .schema app_todo to check the tables of Todo

CREATE TABLE IF NOT EXISTS "app_todo" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "content" varchar(100) NOT NULL, "list_id" bigint NOT NULL REFERENCES "app_todolist" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE INDEX "app_todo_list_id_c59d99ef" ON "app_todo" ("list_id");

Only id, content and list_id are created and three columns missing.

For TodoList:

CREATE TABLE IF NOT EXISTS "app_todolist" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT);

title and create_at are missing.

Please let me know if there is additional information that I should provide.

Thanks a lot!

Please log in or register to answer this question.

...