Skip to content

Instantly share code, notes, and snippets.

@bmispelon
Created July 18, 2013 18:04
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 bmispelon/6031523 to your computer and use it in GitHub Desktop.
Save bmispelon/6031523 to your computer and use it in GitHub Desktop.
Django ticket 20745 Rendering foo.html raises a TypeError whereas bar.html doesn't.
{% extends 'foo.html' %}
{% block foo %}
{{ block.super }}
{% endblock %}
{% load raise %}
{% block foo %}
{% raise 'TypeError' %}
{% endblock %}
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment