为什么我不能将其他 URLs.py 包含到我的 Django 中?

发布于 2024-10-10 15:17:50 字数 931 浏览 0 评论 0原文

我有一个 urls.py。其中之一说这一行:

(r'^notification/?$',include("notification.urls")),

我应该这样做,因为我在 INSTALLED_APPs 中安装了“django_notification”(并添加了“notification”)。

伟大的!去/通知/有效!这是通知模块中的 urls.py:

from django.conf.urls.defaults import *

from notification.views import notices, mark_all_seen, feed_for_user, single, notice_settings

urlpatterns = patterns('',
    url(r'^$', notices, name="notification_notices"),
    url(r'^settings/$', notice_settings, name="notification_notice_settings"),
    url(r'^(\d+)/$', single, name="notification_notice"),
    url(r'^feed/$', feed_for_user, name="notification_feed_for_user"),
    url(r'^mark_all_seen/$', mark_all_seen, name="notification_mark_all_seen"),
)

但是,只有 /notification 有效,并且当我点击该 url 时它会显示“通知”一词。其他都不起作用。 /设置,/饲料。这些都不起作用。我收到一个 404 错误,Django 按顺序尝试了所有 URL。

也许是因为“notification_notice”的原因?

I have a urls.py. One of them says this line:

(r'^notification/?

I'm supposed to do that because I installed "django_notification" (and added "notification") to INSTALLED_APPs.

Great! going to /notification/ works! This is the urls.py in the notification module:

from django.conf.urls.defaults import *

from notification.views import notices, mark_all_seen, feed_for_user, single, notice_settings

urlpatterns = patterns('',
    url(r'^

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

,include("notification.urls")),

I'm supposed to do that because I installed "django_notification" (and added "notification") to INSTALLED_APPs.

Great! going to /notification/ works! This is the urls.py in the notification module:


However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

, notices, name="notification_notices"), url(r'^settings/

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

,include("notification.urls")),

I'm supposed to do that because I installed "django_notification" (and added "notification") to INSTALLED_APPs.

Great! going to /notification/ works! This is the urls.py in the notification module:

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

, notice_settings, name="notification_notice_settings"), url(r'^(\d+)/

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

,include("notification.urls")),

I'm supposed to do that because I installed "django_notification" (and added "notification") to INSTALLED_APPs.

Great! going to /notification/ works! This is the urls.py in the notification module:

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

, single, name="notification_notice"), url(r'^feed/

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

,include("notification.urls")),

I'm supposed to do that because I installed "django_notification" (and added "notification") to INSTALLED_APPs.

Great! going to /notification/ works! This is the urls.py in the notification module:

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

, feed_for_user, name="notification_feed_for_user"), url(r'^mark_all_seen/

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

,include("notification.urls")),

I'm supposed to do that because I installed "django_notification" (and added "notification") to INSTALLED_APPs.

Great! going to /notification/ works! This is the urls.py in the notification module:

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

, mark_all_seen, name="notification_mark_all_seen"), )

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

,include("notification.urls")),

I'm supposed to do that because I installed "django_notification" (and added "notification") to INSTALLED_APPs.

Great! going to /notification/ works! This is the urls.py in the notification module:

However, only /notification works and it displays the word "notice" when I hit that url. Nothing else works. /settings, /feed. None of that work. I get a 404 error that Django tried all the URLs in order.

Perhaps it's because of the "notification_notice" thing??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

青衫儰鉨ミ守葔 2024-10-17 15:17:50

如果您阅读文档,您会发现包含将删除匹配的部分,因此您必须转到 /notification/settings 和 /notification/feed

If you read the documentation, you'll see that the include will remove the part that matches, so you'd have to go to /notification/settings, and /notification/feed

绾颜 2024-10-17 15:17:50

解决了。

我删除了 url 匹配末尾的 ?$

Solved.

I removed the ?$ at the end of the url match.

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