django无法运行mod_wsgi

时间:2014-06-08 12:02:40

标签: python django apache2 mod-wsgi

我尝试在apache2(Ubuntu)上运行我的django项目。我的error.log是:

[Sun Jun 08 11:50:29.635281 2014] [:error] [pid 2582] [client 127.0.0.1:46627]     for url_pattern in get_resolver(None).url_patterns:
[Sun Jun 08 11:50:29.635299 2014] [:error] [pid 2582] [client 127.0.0.1:46627]   File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py", line 350, in url_patterns
[Sun Jun 08 11:50:29.635353 2014] [:error] [pid 2582] [client 127.0.0.1:46627]     raise ImproperlyConfigured("The included urlconf %s doesn't have any patterns in it" % self.urlconf_name)
[Sun Jun 08 11:50:29.635384 2014] [:error] [pid 2582] [client 127.0.0.1:46627] ImproperlyConfigured: The included urlconf kitty.urls doesn't have any patterns in it

和我的wsgi.py

import os
import sys
path = '/home/s/py/django/kitty'
if path not in sys.path:
    sys.path.append(path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "kitty.settings")

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

更新

我的urls.py是:

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    url(r'^', include('frontsite.urls', namespace='frontsite')),
)

1 个答案:

答案 0 :(得分:0)

确保删除在使用内置开发服务器时可能已编译的任何过时urls.pyc文件。如果您将代码复制到单独的Apache安装,包括文件上更改的.pyc文件和日期时间戳,则Apache可以使用陈旧的.pyc文件(如果它具有比相应的.py文件更新的时间戳。)

同时确保如果在Apache上运行应用程序时对Python代码文件进行更改,导致重新启动Apache,则不会重新加载新的代码更改。