簡體   English   中英

django錯誤:NotperlyConfigured:WSGI應用程序

[英]django error: ImproperlyConfigured: WSGI application

我的申請昨晚工作,不知道為什么今天早上不行。 我認為我所做的就是創建一個名為django的應用程序來存儲我的模型,測試和視圖。

得到此錯誤,使用OS X上的Heroku Postgres應用程序和dj_database作為中間件運行django:

  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

我的wsgi.py文件的相關部分:

"""
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)

相關(我認為)我的settings.py文件的一部分:

WSGI_APPLICATION = '{PROJECT}.wsgi.application'

# ...

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

創建一個名為django的應用程序意味着from django import X任何應用程序都將查看您的應用程序,而不是django框架。

在這種情況下,該軟件正在嘗試導入django.core.wsgi ,但現在它正在您的應用程序代碼中查找此文件,在那里無處可尋; 因此錯誤: No module named core.wsgi


為您的應用提供其他名稱。

您必須重命名包含應用程序的文件夾,以及settings.pyINSTALLED_APPS條目。

來自Django 文檔

您需要避免在內置Python或Django組件之后命名項目。 特別是,這意味着你應該避免使用像django (它會與Django本身沖突)或測試 (與內置Python包沖突)這樣的名稱。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM