尝试访问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
是的,我在那里。它究竟做了什么,为什么会抛出错误? – locoboy
因为您试图排除不属于管理员表单的字段。默认情况下,某些字段不会添加到模型表单中。你不能排除不存在的东西; )如果你想看到它,将它添加到'readonly_fields' –
但是我感到困惑的是,如果它明确在models.py中定义,那么为什么它不能在admin.py中使用后,我导入班? – locoboy