public
Created

Django ticket 20745 Rendering foo.html raises a TypeError whereas bar.html doesn't.

  • Download Gist
bar.html
HTML
1 2 3 4 5
{% extends 'foo.html' %}
 
{% block foo %}
{{ block.super }}
{% endblock %}
foo.html
HTML
1 2 3 4 5
{% load raise %}
 
{% block foo %}
{% raise 'TypeError' %}
{% endblock %}
raise.py
Python
1 2 3 4 5 6 7 8 9 10
import builtins
from django import template
 
register = template.Library()
 
@register.simple_tag(name='raise')
def do_raise(exception_name, msg=None):
exception_type = getattr(builtins, exception_name)
args = (msg,) if msg is not None else ()
raise exception_type(*args)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.