2013-02-10 36 views
6

Ứng dụng của tôi đã hoạt động tối qua, không chắc chắn tại sao nó không hoạt động sáng nay. Tôi nghĩ rằng tất cả những gì tôi làm là tạo một ứng dụng gọi là django để lưu trữ các mô hình, kiểm tra và chế độ xem của tôi.lỗi django: Không đúng cấu hình: Ứng dụng WSGI

Bắt lỗi này, chạy django với các ứng dụng Heroku Postgres trên OS X và dj_database như middleware:

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 

phần có liên quan của wsgi.py tập tin của tôi:

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

liên quan (tôi nghĩ) phần trong số settings.py tệp của mình:

WSGI_APPLICATION = '{PROJECT}.wsgi.application' 

# ... 

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

Trả lời

7

Tạo một ứng dụng được gọi là django có nghĩa là bất kỳ from django import X nào sẽ xem xét ứng dụng của bạn, không phải ở khung django.

Trong trường hợp này, phần mềm đang cố gắng nhập django.core.wsgi, nhưng hiện tại, bạn đang tìm kiếm tệp này trong mã của ứng dụng, nơi không tìm thấy nó ở đâu; do đó các lỗi: No module named core.wsgi


Đưa ứng dụng của bạn một tên khác.

Bạn sẽ phải đổi tên thư mục chứa ứng dụng của bạn và mục nhập INSTALLED_APPS trong settings.py.

+0

mà làm được rồi! cảm ơn! – fox

+0

@fox Chúc mừng bạn! Hãy nhớ đảm bảo không bao giờ ghi đè mô-đun khác của Python với mô-đun của bạn:) –

+0

Có, có ý nghĩa. Một câu hỏi bổ sung - ứng dụng không bao giờ được liệt kê trong 'INSTALLED_APPS'. Tôi quên, tôi có phải liệt kê nó ở đó cho django để nhặt nó lên nếu thư mục của ứng dụng nằm trong thư mục dự án hiện tại của tôi (tức là 'project \ app')? – fox

0

từ 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).