我一直在使用[django-registration](https://bitbucket.org/ubernostrum/django-registration),现在我已经开始使用django 1.7b1了,这是我收到下面复制错误的错误。它是从models.py
中的django-registration中提出的:
try:
from django.contrib.auth import get_user_model
User = get_user_model()
except ImportError:
from django.contrib.auth.models import User
并且似乎正在引发它,因为在应用注册表准备好之前调用了get_user_model()
。我不确定这是否是兼容性问题,如果是,是否有一个简单的解决方法?如果没有,你能帮我辨别我做错了吗?
RuntimeError: App registry isn't ready yet.
File "/Users/nima/pe-dev/manage.py", line 9, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/core/management/__init__.py", line 427, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/core/management/__init__.py", line 391, in execute
django.setup()
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/apps/registry.py", line 106, in populate
app_config.import_models(all_models)
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/apps/config.py", line 190, in import_models
self.models_module = import_module(models_module_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Library/Python/2.7/site-packages/registration/models.py", line 15, in <module>
User = get_user_model()
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/contrib/auth/__init__.py", line 136, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL)
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/apps/registry.py", line 187, in get_model
self.check_ready()
File "/Library/Python/2.7/site-packages/Django-1.7b1-py2.7.egg/django/apps/registry.py", line 119, in check_ready
raise RuntimeError("App registry isn't ready yet.")
答案 0 :(得分:25)
不要使用PyPI提供的django-registration。它不支持Django 1.7,它似乎永远不会。回购维护者已退位,项目似乎没有维护。
Github上有一个维护分支,它对我来说对Django 1.7很有用:
https://github.com/macropin/django-registration
可以从PyPI获得django-registration-redux。
https://pypi.python.org/pypi/django-registration-redux/
您可以使用pip安装:
pip install django-registration-redux
答案 1 :(得分:2)
This note解决了您的问题。
我认为导入用户的首选方式是:
from django.conf import settings
User = settings.AUTH_USER_MODEL
编辑:
看起来已经注意到这个问题,但项目管理员很难做出改变。 link。这是Django 1.7中更新的一个更大的问题。
我会说你可以:(1)分叉回购并自己进行更改,或者(2)在pip install之后在你的站点包文件夹中进行更改。如果您将其推送到另一台服务器并使用requirements.txt进行安装,则后一版本也不会起作用。请注意,如果您使用requirements.txt执行选项1,则您希望将其指向您的仓库,而不是Django注册。