我将所有模型存储在一个名为 models 的文件夹中,它对我来说工作正常。但是 admin.py 有一些问题,我应该将这个文件存储在哪里?在模型文件夹或应用程序文件夹中?当我尝试将模型插入管理面板时出现错误。
错误:
TypeError at /admin/
'module' object is not iterable
Request Method: GET
Request URL: http://localhost:9004/admin/
Django Version: 1.4.5
Exception Type: TypeError
Exception Value:
'module' object is not iterable
Exception Location: /usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py in register, line 74
Python Executable: /usr/bin/python2.7
Python Version: 2.7.3
Python Path:
['/home/***/**/**/Testcase_Project',
'/home/***/**/**/Testcase_Project',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
Server time: Sat, 16 Mar 2013 11:31:39 +0200
Traceback Switch to copy-and-paste view
/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py in get_response
request.path_info)
...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py in resolve
for pattern in self.url_patterns:
...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module
__import__(name)
...
▶ Local vars
/home/***/***/***/Testcase_Project/Testcase_Project/urls.py in <module>
admin.autodiscover()
...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/__init__.py in autodiscover
import_module('%s.admin' % app)
...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module
__import__(name)
...
▶ Local vars
/home/***/***/***/Testcase_Project/Testcase_Project/admin.py in <module>
admin.site.register(test_cases)
...
▶ Local vars
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py in register
for model in model_or_iterable:
...
▶ Local vars