我正在寻求完成一个URL:
/group/<group_name>/discussion/<discussion_name>/
我的实施如下所示
url(r'^group/', include('groups.urls')
url(r'^(?P<gslug>[\w-]+)/discussion/', include('discussions.urls')),
url(r'^(?P<slug>[\w-]+)',views.discussion_detail, name='discussion_detail'))
不幸的是,在我的views.discussion_detail
中,我无法访问gslug和slug。我哪里出错?
def discussion_detail(request, gslug, slug):
pass //logic in here
答案 0 :(得分:1)
确保您使用&#39; url&#39;正确地将变量传递到视图中。像这样的模板标签
{% url 'discussion_detail' group.slug discussion.slug %}
如果有效,请告诉我:))