Darwin
Darwin

Reputation: 2037

How I can check current page is home or a special page in template django?

I want to check that current page is home page or not in django template. How I can do this?

Upvotes: 0

Views: 811

Answers (1)

Darwin
Darwin

Reputation: 2037

If we assume that home page url is /, we can check that by

{% if request.path == '/' %}
      <h1 id="nameid" class="display-6 fs-3">{{settings.title}}</h1>
{% else %}
      <h2 id="nameid" class="display-6 fs-3">{{settings.title}}</h2>
{% endif %}

For other page for example about page, we can use {% if request.path == '/about/' %}

Upvotes: 1

Related Questions