2013-02-10 9 views
6

Meine Anwendung arbeitete letzte Nacht, nicht sicher, warum es heute Morgen nicht funktioniert. Ich denke, dass ich nur eine App namens django erstellt habe, um meine Modelle, Tests und Ansichten zu speichern.Django Fehler: Unsachgemäß konfiguriert: WSGI-Anwendung

immer diese Fehlermeldung, django mit der Heroku Postgres-Anwendung auf OS X und dj_database als Middleware ausgeführt wird:

File "/Users/{ME}/Projects/{PROJECT}/{PROJECT}/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 58, in get_internal_wsgi_application 
    "could not import module '%s': %s" % (app_path, module_name, e)) django.core.exceptions.ImproperlyConfigured: WSGI application 
'{PROJECT}.wsgi.application' could not be loaded; could not import module 
'{PROJECT}.wsgi': No module named core.wsgi 

Relevante Teil meiner wsgi.py Datei:

""" 
WSGI config for {PROJECT} project. 

This module contains the WSGI application used by Django's development 
server and any production WSGI deployments. It should expose a 
module-level variable named ``application``. Django's ``runserver`` 
and ``runfcgi`` commands discover this application via the 
``WSGI_APPLICATION`` setting. 

Usually you will have the standard Django WSGI application here, but 
it also might make sense to replace the whole Django WSGI application 
with a custom one that later delegates to the Django one. For example, 
you could introduce WSGI middleware here, or combine a Django 
application with an application of another framework. 

""" 
import os 

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

# This application object is used by any WSGI server configured to use this 
# file. This includes Django's development server, if the WSGI_APPLICATION 
# setting points here. 
from django.core.wsgi import get_wsgi_application 
application = get_wsgi_application() 

# Apply WSGI middleware here. 
# from helloworld.wsgi import HelloWorldApplication 
# application = HelloWorldApplication(application) 

Relevante (glaube ich) Teil meiner settings.py Datei:

WSGI_APPLICATION = '{PROJECT}.wsgi.application' 

# ... 

import dj_database_url 
DATABASES['default'] = dj_database_url.config(default='sqlite://db/sqlite3.db') 

Antwort

7

Erstellen Eine App namens django bedeutet, dass jede from django import X wird Ihre App zu sehen, nicht an der django Rahmen.

In diesem Fall versucht die Software django.core.wsgi zu importieren, aber sie sucht jetzt nach dieser Datei im Code Ihrer App, wo sie nirgendwo zu finden ist; daher der Fehler: No module named core.wsgi


Geben Sie Ihre App einen anderen Namen.

Sie müssen den Ordner, der Ihre App enthält, und den Eintrag INSTALLED_APPS in settings.py umbenennen.

+0

, die es geschafft! Vielen Dank! – fox

+0

@fox Glücklich zu helfen! Denken Sie daran, niemals ein anderes Python-Modul mit Ihrem zu überschreiben:) –

+0

Ja, macht Sinn. Eine zusätzliche Frage - die App wurde nie unter 'INSTALLED_APPS' aufgelistet. Ich vergesse, muss ich es dort für django auflisten, um es aufzuheben, wenn das Verzeichnis der Anwendung in meinem aktuellen Projektverzeichnis ist (d. H. "Project \ app")? – fox

0

aus dem Django documentation:

You’ll need to avoid naming projects after built-in Python or Django components. In particular, this means you should avoid using names like django (which will conflict with Django itself) or test (which conflicts with a built-in Python package).

Verwandte Themen