简体   繁体   English

Django 1.7模型,指定了未知字段(日期)

[英]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.

相关问题 为 UserProfile - Django 指定的未知字段(用户名) - Unknown field(s) (username) specified for UserProfile - Django Django - 为用户指定的未知字段(组) - Django - Unknown field(s) (groups) specified for User django.core.exceptions.FieldError:为 Post 指定的未知字段(模型) - django.core.exceptions.FieldError: Unknown field(s) (model) specified for Post Django1.7:ModelForm没有指定模型类 - Django1.7: ModelForm has no model class specified django.core.exceptions.FieldError:为用户指定的未知字段(出生日期) - django.core.exceptions.FieldError: Unknown field(s) (dateofbirth) specified for User Django Unleashed Cp.22:FieldError:为用户指定了未知字段(用户名) - Django Unleashed Cp.22: FieldError: Unknown field(s) (username) specified for User 尝试 Django 迁移生成错误:“为用户指定的未知字段(组)” - Attempting Django Migration generates Error: "Unknown field(s) (groups) specified for User" django.core.exceptions.FieldError:为配置文件指定了未知字段(电子邮件) - django.core.exceptions.FieldError: Unknown field(s) (email) specified for Profile django.core.exceptions.FieldError:为员工指定的未知字段(用户名) - django.core.exceptions.FieldError: Unknown field(s) (username) specified for Employee django.core.exceptions.FieldError:为客户指定的未知字段(标题) - django.core.exceptions.FieldError: Unknown field(s) (title) specified for Customer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM