Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
升级到Django 1.7-AppRegistryNotReady异常_Django_Wsgi - Fatal编程技术网

升级到Django 1.7-AppRegistryNotReady异常

升级到Django 1.7-AppRegistryNotReady异常,django,wsgi,Django,Wsgi,在将Django版本从1.6.7升级到1.7之后,我一直在努力让它正常工作。看来我不能专注于正确的事情。我试图恢复目前的状况 问题是:如果我在wsgi.py文件中保留命令django.setup(),当我尝试访问我的网站时,我会得到一个内部服务器错误(500)。查看日志,我得到: [Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1] mod_wsgi (pid=23258): Target WSGI script '/home/thrashe

在将Django版本从1.6.7升级到1.7之后,我一直在努力让它正常工作。看来我不能专注于正确的事情。我试图恢复目前的状况

问题是:如果我在wsgi.py文件中保留命令django.setup(),当我尝试访问我的网站时,我会得到一个内部服务器错误(500)。查看日志,我得到:

[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1] mod_wsgi (pid=23258): Target WSGI script '/home/thrasher/webapps/django/myproject.wsgi' cannot be loaded as Python module.
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1] mod_wsgi (pid=23258): Exception occurred processing WSGI script '/home/thrasher/webapps/django/myproject.wsgi'.
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1]   File "/home/thrasher/webapps/django/myproject.wsgi", line 16, in <module>
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1]     application = get_wsgi_application()
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1]   File "/home/thrasher/webapps/django/lib/python2.7/django/core/wsgi.py", line 14, in get_wsgi_application
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1]     django.setup()
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1]   File "/home/thrasher/webapps/django/lib/python2.7/django/__init__.py", line 21, in setup
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1]     apps.populate(settings.INSTALLED_APPS)
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1]   File "/home/thrasher/webapps/django/lib/python2.7/django/apps/registry.py", line 78, in populate
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1]     raise RuntimeError("populate() isn't reentrant")
[Sun Oct 12 12:38:50 2014] [error] [client 127.0.0.1] RuntimeError: populate() isn't reentrant
wgsi.py

import django
from django.core.handlers.wsgi import WSGIHandler


def get_wsgi_application():
    #django.setup()
    return WSGIHandler()

事情看起来很奇怪,我在官方Django文档和各种论坛上进行了大量搜索,但我仍然无法让事情正常运行。如果您有任何建议,我们将不胜感激。

事实证明,问题在于安装的应用程序中存在django.contrib.admin的重复。看来这是问题的根源。当我删除第二个引用后,我在wsgi.py中取消了django.setup()的注释,事情又变得明朗起来。现在一切正常。

您是否在代码中的任何地方使用
get\u user\u model()
?您是否正在调用代码中的任何其他地方的
django.setup()
?嗨@KevinChristopherHenry,不,我没有使用这些方法。事实证明,问题在于安装的应用程序中的django.contrib.admin的重复。看来这是问题的根源。当我删除第二个引用后,我在wsgi.py中取消了django.setup()的注释,事情又变得明朗起来。现在一切都好了。@LucaTrifilio请写下这个作为回答,然后接受它。否则,这个问题将继续作为一个未回答的问题出现。
import os
import sys

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
import django
from django.core.handlers.wsgi import WSGIHandler


def get_wsgi_application():
    #django.setup()
    return WSGIHandler()