55👍
✅
No, but you can use {{ block.super }}
:
{% block extra_head_content %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="/static/css/account.css" />
{% endblock %}
3👍
The django-sekizai module takes care of addition to css and javascript with ease:
#base.html
{% load sekizai_tags %}
# define your template, declaring blocks for inheriting templates:
{% block content %}
{% endblock content %}
# at the bottom of the body:
{% render_block "js" %}
</body>
</html>
#my_template.html
{% extends "base.html" %}
{% load sekizai_tags %}
{% block content %}
# content goes here...
# so does the addtoblock tag
{% addtoblock "js" %}
<script src="my/awesome/script.js"></script>
{% endaddtoblock %}
{% endblock content %}
# Note no addtoblock tags outside the block-endblock tags
The sekazai docs make clear the caveats for using this system, namely that:
- render_block should only be used outside block tags
- render_block cannot be used in included templates
- addtoblock should be used inside block tags when used in an included template
- [Django]-Django filter queryset __in for *every* item in list
- [Django]-Django composite unique on multiple model fields
- [Django]-How can I use Django OAuth Toolkit with Python Social Auth?
Source:stackexchange.com