javascript - Retrieving the URL in Django template language -
In a DJ ango template, how can I mention the URL? To avoid having a live link on the current page, I want to use it in static pages. Is there a way to do this with the Django template language or do I have to use javascript?
I would like to do something like this
{% about about_url == "/ about /"%} about {% else%} & lt; A href = '/ about /' & gt; About & lt; / A & gt; {% Endif%}
I'm using it for a simple blog, so no ideas have been written for those pages.
I think that in the context of your 'static pages' you mean general thoughts internally Use these, RequestContext, so that you have access to the request
object, which is the current HTTPPreference. You can access the current code with request.path
.
{% if request.path == '/ about /'%} ... {% endif%}
Note that this If
syntax Django 1.2+ only - If you are using an older version, you have to:
{% ifequal request.path '/ about / '%} ... {% endifequal%}
Comments
Post a Comment