我正在与django建立一个博客,我试图向模型添加新字段。我还进行了迁移并迁移到数据库。我还尝试了许多其他方法,如stackoverflow,stackoverflow问题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
暂无答案!
目前还没有任何答案,快来回答吧!