3👍
You can use request.path
instead to compare the path of the requested page with the index
url. This will not include the query string if there was any.
A string representing the full path to the requested page, not
including the scheme or domain.
request.get_full_path()
returns the path
along with the query string.
Returns the
path
, plus an appended query string, if applicable.
{% url 'index' as index %}
<div>
{% if request.path == index %} # use request.path instead
This is the index
{% else %}
This is not the index
{% endif %}
</div>
0👍
{% if request.path == request.get_full_path %}
request.path
will give you the relative path without your GET parameters
- [Django]-How to get local datetime from django model DateTimeField?
- [Django]-DRF request.data has no attribute _mutable
- [Django]-What is the format for a PointField in a django fixture?
- [Django]-Serializing Model in Python/Django Template
Source:stackexchange.com