[英]Django 1.7 model, Unknown field(s) (date) specified
I added a model to an application, and now I get this error: 我将模型添加到应用程序中,现在出现此错误:
Unknown field(s) (date) specified for appname
为应用程序名称指定了未知字段(日期)
I have tried python manage.py migrate appname
and it says there are no migrations to make. 我尝试了
python manage.py migrate appname
migration python manage.py migrate appname
,它说没有要进行的迁移。 I've even tried deleting my database and using migrate
and/or syncdb
to recreate it with a clean slate. 我什至尝试删除我的数据库,并使用
migrate
和/或syncdb
重新创建它。 (there's currently no data in there). (当前没有任何数据)。 All to no avail.
一切都无济于事。
My problem seems similar to: Django 1.7 remove field. 我的问题似乎类似于: Django 1.7 remove field。 Unknown field(s) (field) specified for Model
为模型指定了未知字段(字段)
i figured it out. 我想到了。 the problem was with a model form importing a date field with auto_now=True.
问题在于模型表格使用auto_now = True导入日期字段。
I had the same issue, following wasn't working throwing same error as above - 我遇到了同样的问题,以下问题并没有像上面一样引发-
publication_date = models.DateTimeField(auto_now=True, null=True, blank=True)
Where as following worked fine - 如下工作正常-
publication_date = models.DateTimeField(null=True, blank=True)
Strange issue with using auto_now=True
. 使用
auto_now=True
奇怪问题。 Is this limited to version 1.7 only? 仅限于版本1.7吗?
您应该尝试使用默认值=“ xxx”修改auto_now和auto_now_add
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.