Skip to content

Instantly share code, notes, and snippets.

@benjaminrigaud
Created March 31, 2015 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjaminrigaud/e646f51e1a6dfe232c68 to your computer and use it in GitHub Desktop.
Save benjaminrigaud/e646f51e1a6dfe232c68 to your computer and use it in GitHub Desktop.
Django templatetags extends bug in 1.8?

I have two inclusion templatetags specifying their parent template in their context.

In 1.7.7 I have:

hello

content 1

hello 2

content 2

In 1.8c1 I have:

hello

content 1

hello 2

content 1

{% load tags %}
<!DOCTYPE html>
<html>
<body>
{% show_widget_1 'hello' %}
{% show_widget_2 'hello 2' %}
</body>
</html>
from django import template
register = template.Library()
@register.inclusion_tag('widget_1.html')
def show_widget_1(title):
return {
'title': title,
'wrapper': 'wrapper_1.html',
}
@register.inclusion_tag('widget_2.html')
def show_widget_2(title):
return {
'title': title,
'wrapper': 'wrapper_2.html',
}
{% extends wrapper %}
{% block content %}
<div>
<h1>{{ title }}</h1>
content 1
</div>
{% endblock %}
{% extends wrapper %}
{% block content %}
<div>
<h1>{{ title }}</h1>
content 2
</div>
{% endblock %}
{% block content %}
{% endblock content %}
{% block content %}
{% endblock content %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment