https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#url

# template.html
{% load url from future %}

<p>{% url videos pk=video.pk %}</p>


# ----------------------------

While we're at it, consider defining a more verbose name to the url, such
as 'video-detail'. I personally like to map url names to an
'app-model-view' syntax, so you can do something like 'myapp-video-detail'
and rename your 'VideoView' to 'VideoDetail'. Then later have
'myapp-video-list' routing to VideoList and so forth. This is also
consistent with the generic class based views offered by Django and helps
keeping your urls.py organized.



Cheers,
AT


On Wed, Jan 18, 2012 at 1:46 PM, Mark Stahler <markstah...@gmail.com> wrote:

> Can someone explain how to link using url names to class-based views
> that include parameters?
>
> Example:
>
> url(r'^video/(?P<pk>\d+)/$', VideoView.as_view()),
>
> works but all my links have to manually have "/video/{{ video.id }}/"
> or similar. I cannot get {% url videos %}{{ video.id }} to work with
> the following route for some reason.
>
> url(r'^video/(?P<pk>\d+)/$', VideoView.as_view(), name='videos'),
>
> I cant find anything in the documentation about this. Can anyone
> explain?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to