2011-10-31 263 views
1

尝试访问django管理员默认应用程序时,我有以下堆栈跟踪。有谁知道如何修理它?我在目录应用程序的models.py中清楚地定义了字段date_created。我不确定我还需要定义它吗?Django管理问题

ImproperlyConfigured at /admin 

'ProductAdmin.exclude' refers to field 'date_created' that is missing from the form. 

Request Method:  GET 
Request URL: http://localhost:8000/admin 
Django Version:  1.3.1 
Exception Type:  ImproperlyConfigured 
Exception Value:  

'ProductAdmin.exclude' refers to field 'date_created' that is missing from the form. 

Exception Location:  /Library/Python/2.6/site-packages/django/contrib/admin/validation.py in check_formfield, line 362 
Python Executable: /usr/bin/python 
Python Version:  2.6.1 
Python Path:  

['/Users/christopherfarm/Desktop/ecomstore', 
'/Library/Python/2.6/site-packages/python_dateutil-1.5-py2.6.egg', 
'/Library/Python/2.6/site-packages/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg', 
'/Library/Python/2.6/site-packages/django_db_log-2.2.1-py2.6.egg', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python26.zip', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-darwin', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/plat-mac/lib-scriptpackages', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-tk', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-old', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/lib-dynload', 
'/Library/Python/2.6/site-packages', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/PyObjC', 
'/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/wx-2.8-mac-unicode'] 

Server time: Mon, 31 Oct 2011 16:02:11 -0500 

回答

5

我的猜测是,您在models.py字段中设置了auto_now_addauto_add,因此它不是排在首位的表单的一部分。

尝试从您的排除声明中删除它。

+0

是的,我在那里。它究竟做了什么,为什么会抛出错误? – locoboy

+0

因为您试图排除不属于管理员表单的字段。默认情况下,某些字段不会添加到模型表单中。你不能排除不存在的东西; )如果你想看到它,将它添加到'readonly_fields' –

+0

但是我感到困惑的是,如果它明确在models.py中定义,那么为什么它不能在admin.py中使用后,我导入班? – locoboy

0

您是否在初始syncdb之后进行了更改?如果是这样,您需要对相关应用程序执行reset,以便重新加载表格,然后重新创建表格(如果有装置)并重新加载表格。

或者,您可以为您的应用使用dbshell,并使用SQL自行更改表格。

+0

这不是。 – locoboy

0

我有同样的错误。我回到了我一段时间没有处理的项目。我运行它与django==1.5而不是django==1.6上工作。

所以在我的情况总结它与Django的版本连接上1.5我喜欢错误: ExhibitorAdmin.exclude' refers to field 'collectedcontact' that is missing from the form.

同时,切换到django==1.6时,这个问题对我马上消失。