Django管理问题

时间:2011-10-31 21:06:17

标签: python django

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

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

3 个答案:

答案 0 :(得分:5)

我的猜测是,您已在auto_now_add字段中设置了auto_addmodels.py,因此它不是首先要排除的表单的一部分。

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

答案 1 :(得分:0)

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

或者,您可以进入应用程序的dbshell并使用SQL自行更改表。

答案 2 :(得分:0)

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

所以总结一下,在我的情况下,它与1.5上的django版本有关,我得到的错误如下: ExhibitorAdmin.exclude' refers to field 'collectedcontact' that is missing from the form.

而当切换到django==1.6这个问题时,我立即消失了。