How to send parameters in url tag?

24 views
Skip to first unread message

Za Ars

unread,
Sep 20, 2016, 6:51:56 AM9/20/16
to Django users
Hou to send parameters in url as string?

{%url url_name url_params%}

where url_params as 'pk=object.id' or 'page=page.number'


Please, help me, if you can

Alessandro Madruga Correia

unread,
Sep 20, 2016, 10:41:31 AM9/20/16
to django...@googlegroups.com

{%url url_name url_params%}

where url_params as 'pk=object.id' or 'page=page.number'

--
  ,= ,-_-. =.   [<o>] Alessandro Madruga Correia
 ((_/)o o(\_))  [http://counter.li.org]       Debian User# 342751 
   `-'(. .)`-'    "O fanatismo é a única forma de força de vontade 
       \_/        acessível aos fracos." (Friedrich Nietzsche)

Ares Ou

unread,
Sep 20, 2016, 8:17:03 PM9/20/16
to Django users
Hi, 

You have to use a form of keyword arguments to provide parameters in {% url %} tag.

For example,

{% url post_view post_id=post_id %}

the former post_id is the argument name in your view function, the latter post_id is the variable name in your template context.

If you have more than one parameters, just append them to the list, separated by a space:

{% url post_view post_id=post_id tag='post tag' %}
Reply all
Reply to author
Forward
0 new messages