Django“找不到页面”错误页面仅显示两个预期网址之一
我正在与 Django 合作,诚然这是我第一次做真正的事情。
URL 配置如下所示:
urlpatterns = patterns('my_site.core_prototype.views',
(r'^newpost/$', 'newPost'),
(r'^$', 'NewPostAndDisplayList'), # capture nothing...
#more here... - perhaps the perma-links?
)
这是在应用程序的 url.py 中,该 url.py 通过以下方式从项目的 url.py 加载:
urlpatterns = patterns('',
# only app for now.
(r'^$', include('my_site.core_prototype.urls')),
)
问题是,当我收到 404 尝试利用 newpost
时,错误页面仅显示 ^$
——它似乎忽略了 newpost
模式...
我确信解决方案可能很愚蠢,但现在我失踪了它。有人可以帮助我走上正轨吗...
I'm working with Django, admittedly for the first time doing anything real.
The URL config looks like the following:
urlpatterns = patterns('my_site.core_prototype.views',
(r'^newpost/
This is in an app's url.py which is loaded from the project's url.py via:
urlpatterns = patterns('',
# only app for now.
(r'^
The problem is, when I receive a 404 attempting to utilize newpost
, the error page only shows the ^$
-- it seems to ignore the newpost
pattern...
I'm sure the solution is probably stupid-simple but right now I'm missing it. Can someone help get me on the right track...
, 'newPost'),
(r'^
This is in an app's url.py which is loaded from the project's url.py via:
The problem is, when I receive a 404 attempting to utilize newpost
, the error page only shows the ^$
-- it seems to ignore the newpost
pattern...
I'm sure the solution is probably stupid-simple but right now I'm missing it. Can someone help get me on the right track...
, 'NewPostAndDisplayList'), # capture nothing...
#more here... - perhaps the perma-links?
)
This is in an app's url.py which is loaded from the project's url.py via:
The problem is, when I receive a 404 attempting to utilize newpost
, the error page only shows the ^$
-- it seems to ignore the newpost
pattern...
I'm sure the solution is probably stupid-simple but right now I'm missing it. Can someone help get me on the right track...
, include('my_site.core_prototype.urls')),
)
The problem is, when I receive a 404 attempting to utilize newpost
, the error page only shows the ^$
-- it seems to ignore the newpost
pattern...
I'm sure the solution is probably stupid-simple but right now I'm missing it. Can someone help get me on the right track...
, 'newPost'), (r'^This is in an app's url.py which is loaded from the project's url.py via:
The problem is, when I receive a 404 attempting to utilize newpost
, the error page only shows the ^$
-- it seems to ignore the newpost
pattern...
I'm sure the solution is probably stupid-simple but right now I'm missing it. Can someone help get me on the right track...
, 'NewPostAndDisplayList'), # capture nothing... #more here... - perhaps the perma-links? )This is in an app's url.py which is loaded from the project's url.py via:
The problem is, when I receive a 404 attempting to utilize newpost
, the error page only shows the ^$
-- it seems to ignore the newpost
pattern...
I'm sure the solution is probably stupid-simple but right now I'm missing it. Can someone help get me on the right track...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的包含模式将仅匹配空 URL 字符串,将其更改为应映射到包含的 url 的前缀,或从该模式中删除 $。
Your pattern for the include will only match an empty URL string, change it to a prefix which should be mapped to the included urls, or remove the $ from that pattern.