2013-02-10 15 views
6

मेरा आवेदन कल रात काम कर रहा था, यह सुनिश्चित नहीं है कि यह आज सुबह क्यों काम नहीं करेगा। मुझे लगता है कि मैंने अपने मॉडल, परीक्षण और विचारों को स्टोर करने के लिए django नामक एक ऐप बनाना था।django त्रुटि: अनुचित रूप से कॉन्फ़िगर किया गया: डब्लूएसजीआई आवेदन

इस त्रुटि हो रही है, ओएस एक्स पर 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') 

उत्तर

7

बनाना django नामक एक ऐप का अर्थ है कि from django import Xdjango ढांचे पर नहीं, आपके ऐप को देख रहा है।

इस मामले में, सॉफ्टवेयर django.core.wsgi आयात करने का प्रयास कर रहा है, लेकिन अब यह आपके ऐप के कोड में इस फ़ाइल को ढूंढ रहा है, जहां यह कहीं भी नहीं है; इसलिए त्रुटि: No module named core.wsgi


अपने अनुप्रयोग एक और नाम दें।

आपको उस फ़ोल्डर का नाम बदलना होगा जिसमें आपका ऐप है, और INSTALLED_APPSsettings.py में प्रविष्टि।

+0

है कि यह किया! धन्यवाद! – fox

+0

@fox मदद करने के लिए खुश! यह सुनिश्चित करना याद रखें कि कभी भी आपके साथ किसी अन्य पायथन के मॉड्यूल को ओवरराइड न करें:) –

+0

हां, समझ में आता है। एक अतिरिक्त सवाल - ऐप को 'INSTALLED_APPS' के तहत कभी सूचीबद्ध नहीं किया गया था। मैं भूल जाता हूं, क्या मुझे इसे जोड़ने के लिए django के लिए इसे सूचीबद्ध करना होगा यदि ऐप की निर्देशिका मेरी वर्तमान प्रोजेक्ट निर्देशिका (यानी 'प्रोजेक्ट \ एपी') में है? – fox

0
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).

संबंधित मुद्दे