25 Jun 2020

Django - template extending

  • django
  • concepts
  • python
  • Template extending means you can reuse same parts of HTML for different pages of website and prevent you from code repetition.

    How To

    1. Create a base template templates/base.html
    2. Replace the part which content is dependent on other templates with {% block content %}{% endblock %}
    3. In other templates, extend base.html and code what should be inside of {% block content %}{% endblock %}