我在django中得到一個導入錯誤。我的主要urls.py設置文件位於main/main/urls.py
我的模塊或應用程序位於main/apps/builder/urls.py
。django沒有找到應用程序
追蹤誤差
ImportError at/
No module named apps.builder.urls
Request Method: GET
Request URL: ***************
Django Version: 1.4
Exception Type: ImportError
Exception Value:
No module named apps.builder.urls
Exception Location: /usr/lib/python2.6/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable: /usr/bin/python26
Python Version: 2.6.0
Python Path:
['/home/pycode/main',
'/usr/lib/python26.zip',
'/usr/lib/python2.6',
'/usr/lib/python2.6/plat-linux2',
'/usr/lib/python2.6/lib-tk',
'/usr/lib/python2.6/lib-old',
'/usr/lib/python2.6/lib-dynload',
'/usr/lib/python2.6/site-packages']
Server time: Tue, 12 Jun 2012 12:39:17 -0500
主/主/ urls.py
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^$', include('main.apps.builder.urls')),
)
只用'apps.builder.urls'或'main.main.apps.builder.urls'試試看,我猜這跟你佈置應用程序的方式有關。還要確保你在所有文件夾中都有__init__.py – ramdaz