Domanda

I'm looking to accomplish a URL as so:

/group/<group_name>/discussion/<discussion_name>/

My implementation is shown below

project urls.py

url(r'^group/', include('groups.urls')

group urls.py

url(r'^(?P<gslug>[\w-]+)/discussion/', include('discussions.urls')),

discussion urls.py

url(r'^(?P<slug>[\w-]+)',views.discussion_detail, name='discussion_detail'))

Unfortunately in my views.discussion_detail I do not have access to both gslug and slug. Where have I gone wrong?

discussion views.py

def discussion_detail(request, gslug, slug):
  pass //logic in here
È stato utile?

Soluzione

Make sure that you're passing variables into the view properly with the 'url' template tag like so

{% url 'discussion_detail' group.slug discussion.slug %}

Let me know if that works :)

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top