【发布时间】:2013-10-21 06:19:03
【问题描述】:
我的网址:
url(r'^(?P<task_id>\d+)/note/$', login_required(NoteView.as_view()), name='note'),
笔记成功保存后,我想重定向到带有task_id的笔记url,因此我使用reverse函数:
return HttpResponseRedirect(reverse('website.views.note', args=(task_id,)))
我的网址如下所示:
http://localhost:8000/1/note/
我认为反向只适用于http://localhost:8000/note/1/,但不适用于http://localhost:8000/1/note/。我怎样才能让它发挥作用?
【问题讨论】:
-
你为什么要在
/1/note而不是/note/1? -
应用程序中的整个 URL 模式是
/1/note。只是想让它统一,仅此而已。 -
在发送参数时尝试使用列表而不是元组。
-
是的,还是不行:(
-
@user2032220 你能显示
/note/1url 定义吗?
标签: django django-urls