Created
January 29, 2014 14:02
-
-
Save adamghill/8688581 to your computer and use it in GitHub Desktop.
Load arbitrary content from templates without creating a ton of unnecessary view methods.
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.http import Http404 | |
from django.shortcuts import render_to_response | |
from django.template import RequestContext, TemplateDoesNotExist | |
def content(request, template_name): | |
try: | |
return render_to_response('content/' + template_name + '.html', {}, RequestContext(request)) | |
except TemplateDoesNotExist: | |
raise Http404 |
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.conf.urls import patterns, url | |
from .content_views import content | |
urlpatterns = patterns('', | |
url(r'^(.*?)/$', content, name='content'), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment