没有这样的专栏:blog_article.date

时间:2016-01-31 00:02:30

标签: python django django-models django-admin

尝试在文章的管理面板中添加DateTimeField

Exception Type:     OperationalError
Exception Value:    no such column: blog_article.date

Admin.py

from django.contrib import admin
from blog.models import Article

class ArticleAdmin(admin.ModelAdmin):
  list_display = ('title', 'date')

admin.site.register(Article, ArticleAdmin)

Models.py

from django.contrib.auth.models import User
from django.db import models

class Article(models.Model):
    title = models.CharField(max_length=200)
    text = models.TextField("Text")
    date = models.DateField()
    user = models.ForeignKey(User)

1 个答案:

答案 0 :(得分:0)

在终端中尝试此命令:

  1. python manage.py makemigrations
  2. python manage.py migrate
  3. 替代: 排除位于文件夹/ migrations /中的迁移,然后重新进行迁移。