0

Perhaps I'm coming at my problem with a WordPress mindset but what i'd like to achieve is the notion of a parent/child theme for Django projects. I think I can solve the template issue by defining two template directories

TEMPLATE_DIRS = (
  '/home/Username/webapps/django/child/templates',
  '/home/Username/webapps/django/parent/templates',
)

But is there a way to achieve this with the static files? For example, we add a new feature to the parent, update the parent app which updates the templates along with adding some new javascript, LESS, and images.

Colin
  • 255
  • 1
  • 10

1 Answers1

1

You don't need to specify two template directories. There is a concept of parent and child templates. All child templates extends the parent:

base.html (we often use this name for parent)

<html>
    <head>
       <!-- Some css, js stuff goes here-->
       {% block extra_head %}
           <!-- A block where child templates add more css and js stuff if needed -->
       {% endblock extra_head %}
    </head>
    <body>
        {% block body %}
           <!-- body content here -->
        {% endblock body %}
    </body>
</html>

And then child template will extend the base.html as:

child.html

{% extends "base.html" %}

{% block body %}
    <h1>Hello!</h1>
{% endblock body %}
Aamir Rind
  • 38,793
  • 23
  • 126
  • 164