【发布时间】:2021-09-20 00:33:55
【问题描述】:
我正在用 django 建立一个博客,并尝试向模型中添加新字段。我还进行了迁移并迁移到数据库。我还尝试了许多其他的事情,例如 stackoverflow,stackoverflow question 2 但我终于得到了在/没有这样的列出现操作错误:
from django.db import models
from django.contrib.auth.models import User
from ckeditor.fields import RichTextField
STATUS = (
(0,"Draft"),
(1,"Publish")
)
class Post(models.Model):
title = models.CharField(max_length=200, unique=True)
slug = models.SlugField(max_length=200, unique=True)
author = models.ForeignKey(User, on_delete=
models.CASCADE,related_name='blog_posts')
updated_on = models.DateTimeField(auto_now= True)
content = RichTextField(blank=True, null=True)
created_on = models.DateTimeField(auto_now_add=True)
status = models.IntegerField(choices=STATUS, default=0)
image = models.ImageField(upload_to='images',null=True, blank=True)
class Meta:
ordering = ['-created_on']
def __str__(self):
return self.title
【问题讨论】:
-
请用准确的错误跟踪更新问题...
标签: python django django-models