fred
fred

Reputation: 1303

How do I do display content in Django based on URL and all recurisive urls

So I have this in a Django template.

{% if request.get_full_path = "/blog/" %}
   do something
{% endif %}

Which does exactly what I want when I go to http://somesite.com/blog/

What I want to do is also include all subdirectories.

So something like

{% if request.get_full_path = "/blog/*" %}
   do something
{% endif %}

Unfortunately as far as I can tell Django doesn't do wildcards in templates. So how do I do this?

Upvotes: 0

Views: 223

Answers (1)

juliocesar
juliocesar

Reputation: 5876

Try with this:

{% if request.get_full_path|slice:'0:6' == '/blog/' %}

Upvotes: 1

Related Questions