How to check if this is the index page in Django?

Question:

How can I check of the present page is the index page in a Django template?

{% if What Goes Here??? %}

// whatever

{% endif %}
Asked By: Tyler

||

Answers:

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.request',
    ...
)


{% if request.path == "/" %}
    ...
{% endif %}
Answered By: Timmy O'Mahony

You can just add your template code to the index page template itself.

Answered By: rolling stone
{% if request.resolver_match.url_name == 'index' %}

// whatever

{% endif %}
Answered By: GeorgeJungg
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.