1π
It sounds like you are after the following
^(?P<cat_name>[\w-]+)/(?P<story_id>\d+)$
which would match up to the view
def category(request, cat_name, story_id):
category = Category.objects.get(category_name=cat_name)
stories = Story.objects.filter(category=category)
Note: you may wish to change what characters are allowed for the category name and this is a pretty wide open regex and may cause you a little trouble with similar urls in the future.
π€Sayse
0π
You should use:
url(r'^(?P<category_name>\w+)/(?P<story_id>[0-9]+)/$', 'stories.views.comment'),
And in the comment function, define as:
def category(request, category_name, story_id):
π€Dric512
- Notifications system has issues
- Running a python commands from a python script in a python (Django) shell. Django
- Fill django form using bootstrap selectbox
Source:stackexchange.com