为什么我不能将其他 URLs.py 包含到我的 Django 中?
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您阅读文档,您会发现包含将删除匹配的部分,因此您必须转到 /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
解决了。
我删除了 url 匹配末尾的
?$
。Solved.
I removed the
?$
at the end of the url match.