Created
June 3, 2016 10:09
-
-
Save kezabelle/d9c96542b2d48c1fbae95bcdc6fe6988 to your computer and use it in GitHub Desktop.
for BPL in #django IRC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.template import TemplateDoesNotExist, get_template | |
def path_to_file(request, template_name): | |
# assert template_name in some_safe_list if you want. | |
try: | |
get_template(template_name) | |
except TemplateDoesNotExist: | |
return render("some_fallback.html", request, context) | |
return render(template_name, request, context) | |
urlconf_mountpoint = url(regex=r'^(?P<template_name>.+)/$', view=path_to_file, name='staticpage') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment