Reputation: 15443
I'm trying the django-cms tutorial, There is something I don't understand at the end of this part :
I have to add a template at /mysite/templates/polls/base.html. But this file has to begin with {% extends 'base.html' %}
.
Is that normal? Is the file this line refers to an other base.html file? The one in the parent directory perhaps? I'm not sure at all.
Thank you for your help.
Upvotes: 1
Views: 13140
Reputation: 12869
Extending from a base.html
like that would suggest, like I do, that you have a base.html
file at the root template directory of your project to handle the core markup;
{% load cms_tags menu_tags sekizai_tags cache i18n %}
{% load static from staticfiles %}
<head>
<meta charset="utf-8">
{% block head %}{% endblock head %}
<title>
<script type="text/javascript"
src="{% static 'project/external/jquery-1.11.2.min.js' %}"></script>
{% render_block "css" %}
{% render_block "js" %}
{% block styles %}{% endblock styles %}
{% block scripts %}{% endblock scripts %}
</head>
<body>
{% cms_toolbar %}
{% block content %}
{% endblock content %}
{% block footer-scripts %}{% endblock footer-scripts %}
</body>
</html>
That way, when you setup templates in your apps you can start with a base.html
for that app which may extend the base blocks for the head tag or elsewhere.
Usually I have a setup similar to myproj/templates
and then app templates like myproj/project/templates
and myproj/app1/templates
. That first templates dir sits next to manage.py
and I use the project
dir to hold settings & any templates specific to that project like types of CMS page; article.html
etc.
You don't have to extend base.html
but if you don't, then you need to recreate all that markup again so by using this template model you'll be able to limit repeated markup.
Upvotes: 5