Django“找不到页面”错误页面仅显示两个预期网址之一

发布于 2024-08-30 13:13:24 字数 625 浏览 3 评论 0原文

我正在与 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

轻拂→两袖风尘 2024-09-06 13:13:24

您的包含模式将仅匹配空 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文