Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Django Template {{ block.super }} example
# Template: A.html
<html>
<head></head>
<body>
{% block hello %}
HELLO
{% endblock %}
</body>
</html>
# Template B.html
{% extends "A.html" %}
{% block hello %}
World
{% endblock %}
# Rendered Template B
<html>
<head></head>
<body>
World
</body>
</html>
# Template C
{% extends "A.html" %}
{% block hello %}
{{ block.super }} World
{% endblock %}
# Rendered Template C
<html>
<head></head>
<body>
Hello World
</body>
</html>
@rahulkp220

This comment has been minimized.

Copy link

commented Jun 4, 2016

Thanks. Helped me to understand it more clearly :-)

@alonek1

This comment has been minimized.

Copy link

commented Jun 20, 2016

thanks

@toti1212

This comment has been minimized.

Copy link

commented Aug 15, 2016

👍 Nice!

@laoyur

This comment has been minimized.

Copy link

commented Aug 21, 2016

nice example !

@jaskaran1989

This comment has been minimized.

Copy link

commented Sep 6, 2016

thanks for explaining this clearly

@juliotoscano

This comment has been minimized.

Copy link

commented Nov 10, 2016

Thanks so much!

@emm7494

This comment has been minimized.

Copy link

commented Jan 11, 2017

Very helpful

@emacstheviking

This comment has been minimized.

Copy link

commented Jan 17, 2017

Surely that's wrong??? Template C should inherit from template B other it won't work will it?

@Ausqa21

This comment has been minimized.

Copy link

commented Jan 27, 2017

Thanks a lot for the explanation

@nagracks

This comment has been minimized.

Copy link

commented Mar 2, 2017

Thanx

@onitonitonito

This comment has been minimized.

Copy link

commented May 23, 2017

very helpful! Thanx

@diek

This comment has been minimized.

Copy link

commented Sep 22, 2017

Nice example, I created a simple working version. https://github.com/diek/superduper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.