我目前正在尝试使用 django 开发一个相当简单的应用程序,但我一开始就卡住了:我的项目名为“kundencenter”,我的应用程序是“customermgr”。
项目和应用程序都有一个urls.py
,项目urls.py
包括应用程序的:
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^customer/', include('kundencenter.customermgr.urls')),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),
)
但是当我现在尝试访问时customer/
,我会看到一个ImportError
:
Django Version: 1.4
Exception Type: ImportError
Exception Value:
No module named customermgr.urls
Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /usr/bin/python
Python Version: 2.7.1
Python Path:
['/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'.',
'/var/www/kundencenter',
'/var/www']
如您所见,我已经对 . 发疯了PYTHONPATH
,但无济于事。正如您可能已经猜到的那样,该项目位于/var/www/kundencenter
. 我还检查了__init__.py
文件是否已创建,它们是(它们是空的)。当我运行manage.py runserver
并使用带有 mod_wsgi 的 Apache 时出现错误。
我的智慧已经走到了尽头。有谁知道我怎样才能摆脱这个错误?