我正在尝试将生菜添加到现有的Django 项目中。配置了一个非常简单的功能目录后,我不断得到django.contrib.admin.sites.AlreadyRegistered
:模型系列已经注册。我检查了不同的导入(例如import .models
vs import reg.models
)、重复导入和错误的应用程序,这些应用程序可能重新导入了我的 admin.py 无济于事。该错误似乎来自尝试重新加载模块的生菜。我不确定它为什么要这样做。追溯如下。
(dwcoop)s001 cro-mbp[126]% DJANGO_SETTINGS_MODULE=settings.testing django-admin.py harvest reg
Creating test database for alias 'default'...
Django's builtin server is running at 0.0.0.0:8000
Traceback (most recent call last):
File "/Users/cro/src/ve/dwcoop/lib/python2.7/site- packages/lettuce/django/management/commands/harvest.py", line 167, in handle
result = runner.run()
File "/Users/cro/src/ve/dwcoop/lib/python2.7/site-packages/lettuce/__init__.py", line 137, in run
self.loader.find_and_load_step_definitions()
File "/Users/cro/src/ve/dwcoop/lib/python2.7/site-packages/lettuce/fs.py", line 60, in find_and_load_step_definitions
reload(module) # always take fresh meat :)
File "/Users/cro/src/ve/dwcoop/web/web/reg/admin.py", line 60, in <module>
admin.site.register(Family, FamilyAdmin)
File "/Users/cro/src/ve/dwcoop/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 83, in register
raise AlreadyRegistered('The model %s is already registered' % model.__name__)
AlreadyRegistered: The model Family is already registered
Destroying test database for alias 'default'...