[Answer]-Django Templates: How to filter based on the URL?

1👍

You can use request.path in the template to get the current url like so:

{% if request.path == '/dashboard/' %}
   <!-- conditional html content -->
{% endif %}

For this to work you must have django.core.context_processors.request listed in your TEMPLATE_CONTEXT_PROCESSORS in your settings.py file.

Leave a comment