import os.path from django.http import Http404 from django.views.generic.simple import direct_to_template from settings import DEPLOY_PATH def index(request, page): template = 'html_pages/%s/index.html' % page if not os.path.exists('%s/templates/%s' % (DEPLOY_PATH, template): raise Http404 c = { "page": template, } return direct_to_template(request, "pages/index.html", c)