Django template, if tag based on current URL value

You can also do this for dynamic urls using:

{% url 'show_user_page' user=user as the_url %}
{% if request.get_full_path == the_url %}something{% endif %}

where your urls.py contains something like:

(r'^myapp/user/(?P<user>\d+)/$', 'show_user_page'),

I know this because I just spent ages drafting a stackoverflow question, when I found the answer in the docs.

I’d say even in simple cases this might be the better approach, because it is more loosely coupled.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)