【发布时间】:2013-12-18 10:37:26
【问题描述】:
我的 urls.py 中有以下代码:
urlpatterns = patterns('',
(r'^news/', include('news.urls')),
)
当我尝试打开时
http://localhost/news
或
http://localhost/news/
在浏览器 django 中显示 404 页面:
Using the URLconf defined in python.urls, Django tried these URL patterns, in this order:
^news/
The current URL, , didn't match any of these.
UPD:
新闻/urls.py:
from django.conf.urls.defaults import *
from django.views.generic.simple import direct_to_template
urlpatterns = patterns('news.views',
(r'^$', 'news'),
)
news目录下有views.py,里面有新闻功能。
并将新闻模块添加到 INSTALLED_APPS。
为什么找不到新闻模式?有什么建议吗?
【问题讨论】:
-
向我们展示您的
news/urls.py? -
URLconf defined in python.urls -
我从未听说过 loca。听起来不错(你在这里少了一个 l --> localhost/news)
-
是的,'loca...' 在我的问题中是错字