2016-01-17 4 views
7

Ich habe mit einem Django Tutoirus von Microsoft gespielt, die in meiner Visual Studio 2015-Umgebung mit Python 3.4.3 funktionierte. Wenn ich versuche, es mir durch den Webserver zu laufen, wird es andernfalls aber:Django auf IIS: django.core.exceptions.AppRegistryNotReady: Apps sind noch nicht geladen

Error occurred: 

Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\wfastcgi.py", line 805, in main 
    result = handler(record.params, response.start) 
    File "C:\Python34\lib\site-packages\django\core\handlers\wsgi.py", line 158, in __call__ 
    self.load_middleware() 
    File "C:\Python34\lib\site-packages\django\core\handlers\base.py", line 51, in load_middleware 
    mw_class = import_string(middleware_path) 
    File "C:\Python34\lib\site-packages\django\utils\module_loading.py", line 20, in import_string 
    module = import_module(module_path) 
    File "C:\Python34\lib\importlib\__init__.py", line 109, in import_module 
    return _bootstrap._gcd_import(name[level:], package, level) 
    File "<frozen importlib._bootstrap>", line 2254, in _gcd_import 
    File "<frozen importlib._bootstrap>", line 2237, in _find_and_load 
    File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked 
    File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked 
    File "<frozen importlib._bootstrap>", line 1129, in _exec 
    File "<frozen importlib._bootstrap>", line 1471, in exec_module 
    File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed 
    File "C:\Python34\lib\site-packages\django\contrib\auth\middleware.py", line 3, in <module> 
    from django.contrib.auth.backends import RemoteUserBackend 
    File "C:\Python34\lib\site-packages\django\contrib\auth\backends.py", line 4, in <module> 
    from django.contrib.auth.models import Permission 
    File "C:\Python34\lib\site-packages\django\contrib\auth\models.py", line 4, in <module> 
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager 
    File "C:\Python34\lib\site-packages\django\contrib\auth\base_user.py", line 49, in <module> 
    class AbstractBaseUser(models.Model): 
    File "C:\Python34\lib\site-packages\django\db\models\base.py", line 94, in __new__ 
    app_config = apps.get_containing_app_config(module) 
    File "C:\Python34\lib\site-packages\django\apps\registry.py", line 239, in get_containing_app_config 
    self.check_apps_ready() 
    File "C:\Python34\lib\site-packages\django\apps\registry.py", line 124, in check_apps_ready 
    raise AppRegistryNotReady("Apps aren't loaded yet.") 
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. 


StdOut: 

StdErr: 

Wenn ich den Code über „manage.py runserver“ testen auf dem Webserver, es funktioniert perfekt. Hat jemand irgendwelche Empfehlungen zum Debuggen, was schief läuft, wenn es über IIS läuft?

Der Server läuft auch mit Python 3.4.3, mit django, django-crispy-forms, wfastcgi und mysqlclient. Python ist über FastCGI auf einem Windows 2012 R2 Server mit IIS 8.5 ausgeführt - Konfiguration durchgeführt wurde mit der Führung in https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-python-django-web-app-windows-server/

Ich habe versucht:

1) Hinzufügen des folgenden unter "o env ..." in meinem manage.py:

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

2) Hinzufügen der folgenden unter "os env ..." in meinem manage.py:

import django 
django.setup() 

Wie andere Menschen erwähnt, diese Lösungen in o Die Fäden, aber leider ohne Glück. Ich bin komplett neu in Python/Django, also habe ich keine Ahnung, wie es weitergehen soll. Jede Eingabe würde sehr geschätzt werden!

+0

ich mal ein ähnliches Problem hatte. Es war eine schlechte Initialisierung der wsgi App. Der Aufruf hat sich über die Versionen von Django geändert, und das Tutorial könnte Ihre Sprache nicht abdecken. –

Antwort

13

Es stellt sich heraus, dass der verknüpfte Microsoft-Leitfaden veraltet ist.

In web.config, die folgenden Anforderungen ersetzt werden:

<add key="WSGI_HANDLER" value="django.core.handlers.wsgi.WSGIHandler()" /> 

mit:

<add key="WSGI_HANDLER" value="django.core.wsgi.get_wsgi_application()" /> 

und dann wird es funktionieren :-)

+1

Für was es wert ist ... Danke. Du hast mein Projekt nach 48 Stunden Nonsense Trial-and-Error gerettet. –