Я думаю, что следовал правильному процессу, чтобы заставить миграции работать, но изменения, похоже, не вступили в силу. Я пытаюсь добавить поле слагов в свой класс комментариев field=models.SlugField(blank=True, max_length=500)
.
Схема
sqlite> .schema blog_Comment
CREATE TABLE IF NOT EXISTS "blog_comment" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "name" varchar(80) NOT NULL, "email" varchar(254) NOT NULL, "body" text NOT NULL, "created_on" datetime NOT NULL, "active" bool NOT NULL, "post_id" integer NOT NULL REFERENCES "blog_post" ("id") DEFERRABLE INITIALLY DEFERRED);
CREATE INDEX "blog_comment_post_id_580e96ef" ON "blog_comment" ("post_id");
sqlite>
0017_auto_20200426_2137.py
# Generated by Django 2.2.6 on 2020-04-26 14:37
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('blog', '0016_auto_20200426_0209'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='created_on',
field=models.DateTimeField(default=datetime.datetime(2020, 4, 26, 14, 37, 27, 23071, tzinfo=utc)),
),
migrations.AlterField(
model_name='comment',
name='url',
field=models.SlugField(blank=True, max_length=500),
),
migrations.AlterField(
model_name='post',
name='date_posted',
field=models.DateTimeField(default=datetime.datetime(2020, 4, 26, 14, 37, 27, 23071, tzinfo=utc)),
),
]
Комментарий класса (models.Model):
class Comment(models.Model):
post = models.ForeignKey(Post,on_delete=models.CASCADE,related_name='comments')
name = models.CharField(max_length=80)
email = models.EmailField()
body = models.TextField()
created_on= models.DateTimeField(default = timezone.now())
active = models.BooleanField(default=False)
url= models.SlugField(max_length=500, blank=True)