Inte L
Inte L

Reputation: 345

My Django if statement do not work correctly

I have created a admin panel on the frontend and would like to show different layouts if they are on the index.html or if they are on pages after /admin e.g:

/admin/dashboard
/admin/posts
/admin/media

My if statement:

{% if request.path == "/admin" %}

It doesn't work for some reason and I can't figure out why. This is an example of the whole if:

<div class="row">

{% if request.path == "/admin" %}
<div class="col-md-full">
{% else %}
<div class="col-md-7 left">
  {% block main %}{% endblock %}
</div>
{% endif %}

{% if request.path == "/admin" %}
{% trans "Empty" %}
{% else %}
<div class="col-md-3 right">
    <div class="panel panel-default">
    <div class="panel-body">
    {% block right_panel %}
    {% endblock %}
    </div>
    </div>
</div>
{% endif %}

</div>

Upvotes: 2

Views: 62

Answers (1)

doniyor
doniyor

Reputation: 37846

what about?

{% if '/admin/' in request.path %}

Upvotes: 3

Related Questions