1
When you extend a template you need to make sure all of the code in the child template is inside a block. So for your main template typically you do something like:
main.html
{% load staticfiles %} <!-- This should go at the top for readability -->
<!-- Load any site wide JS here -->
<script type="text/javascript" src="{% static 'main.js' %}"></script>
{% block js %}<!-- Put JS in here for extended templates -->{% endblock %}
detail.html
{% extends 'layout/main.html' %}
{% load staticfiles %}
{% block js %}
<script type="text/javascript" src="{% static 'fancybox.js' %}"></script>
{% endblock %}
{% block title %}
<!-- SOME CONTENT -->
{% endblock %}
0
{% extends 'layout/main.html' %} {% block title %} {% load staticfiles %} <script type="text/javascript" src="{% static 'fancybox.js' %}"></script> <!-- SOME CONTENT --> {% endblock %}
use this code in details.html.You have to put {% block body%}
at the top just after the extend or include statement
- How to create nested form in django?
- Django too many open files
- Django where should I put my CSS file
- Django Rest Framework Auth
- Extra row on Bootstrap navigation bar
Source:stackexchange.com