我确信这只是我可以忽略的东西,但是我太烦恼了,不能单独解决它,所以提前感谢。
项目目录结构 * 已更新 *
myproject/
manage.py
myproject/
apps/
geo/
urls.py
settings.py
urls.py
urls.py
from django.conf import settings
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
from django.contrib.gis import admin
admin.autodiscover()
from pinax.apps.account.openid_consumer import PinaxConsumer
handler500 = "pinax.views.server_error"
urlpatterns = patterns("",
url(r"^$", direct_to_template, {'template' : 'home.html' }, name="home"),
url(r"^admin/invite_user/$", "pinax.apps.signup_codes.views.admin_invite_user", name="admin_invite_user"),
url(r"^admin/", include(admin.site.urls)),
url(r"^about/", include("apps.about.urls")),
url(r"^account/", include("pinax.apps.account.urls")),
url(r"^openid/", include(PinaxConsumer().urls)),
url(r"^profiles/", include("idios.urls")),
url(r"^notices/", include("notification.urls")),
url(r"^announcements/", include("announcements.urls")),
url(r"^products/", include("products.urls")),
url(r"^locate/", include("geo.urls")),
url(r"^sectors/", include("sectors.urls")),
)
if settings.SERVE_MEDIA:
urlpatterns += patterns("",
url(r"", include("staticfiles.urls")),
)
settings.py
INSTALLED_APPS = [
# project
"tulsa-site.apps.about",
"tulsa-site.apps.profiles",
"tulsa-site.apps.geo",
"tulsa-site.apps.sectors",
]
当我进入url路径“http://127.0.0.1:8000/locate/”时收到错误消息:我收到异常值“没有名为geo.urls的模块”。我错过了什么?
答案 0 :(得分:0)
include("geo.urls")
告诉Django相对于geo.urls
文件查找manage.py
。所以它基本上寻找这个文件:
myproject/
manage.py
myproject/
apps/
settings.py
urls.py
geo/
urls.py <- this file
这是一种以Django 1.4开头的新目录结构,鼓励让应用程序独立于Django项目。但是,如果您仍然遵循应用程序文件夹在项目文件夹中的旧布局,则必须更改导入以反映:
include("myproject.geo.urls")
修改强>
按照更新的布局:
include("myproject.apps.geo.urls")
答案 1 :(得分:0)
url(r"^locate/", include("tulsa-site.apps.geo.urls"))