I need to change the margin-left that is applied to my main {% block content %} in my base.html template (that contains my navbar and other common elements) based on if the viewer is using mobile or desktop.
My current base.html is like:
<div class="content container-fluid">
<div class="row">
<div class="col-md-8">
{% block content %}
{% endblock %}
</div>
</div>
</div>
with a css file containing:
.content {
margin-left: 40px;
}
.content_mobile {
margin-left: 10px;
}
Given that in other parts of my application I've accomplished something similar by using the following dedicated Bootstrap classes, my first thought was to do the same using something like:
<div class=".visible-xs-block, hidden-xs">
<div class="content container-fluid">
<div class="row">
<div class="col-md-8">
<!-- This is hidden from mobile view -->
{% block content %}
{% endblock %}
</div>
</div>
</div>
</div>
<div class=".visible-lg-block, hidden-lg .visible-md-block, hidden-md .visible-sm-block, hidden-sm">
<div class="content_mobile container-fluid">
<div class="row">
<div class="col-md-8">
<!-- This is hidden from all other views (including desktop) -->
{% block content %}
{% endblock %}
</div>
</div>
</div>
</div>
But Django raises an exception because it can only render 1 {% block content %} per template!
Any ideas how I can do this without using multiple blocks?