[Answered ]-Django – different html/css/js code for each page

2👍

Create base.html

base.html

<html>
   <head>
       <title>{% block title %}{% endblock %}</title>

       {% block css %}{% endblock %}
       {% block js %}{% endblock %}
   </head>

   <body>
        {% block content %}{% endblock %}
   </body>
</html>

page1.html

{% extends "base.html" %}

{% block title %}{{block.super}}"title here"{% endblock %}

{% block css %}{{block.super}}
     "css here"
{% endblock %}

{% block js %}{{block.super}}
     "js here"
{% endblock %}

{% block content %}
     content here
{% endblock %}

Follow this pattern in other pages and you can now use different css/js as you want

Leave a comment