增加 admin 后台返回执行模板的 views 函数

This commit is contained in:
virusdefender 2015-08-05 19:47:49 +08:00
parent 21e977f409
commit 5eacb9f3d7

View File

@ -1,3 +1,14 @@
from django.shortcuts import render
# coding=utf-8
from django.conf import settings
from django.http import HttpResponse, Http404
# Create your views here.
from rest_framework.views import APIView
class AdminTemplateView(APIView):
def get(self, request, template_dir, template_name):
path = settings.TEMPLATE_DIRS[0] + "/admin/" + template_dir + "/" + template_name + ".html"
try:
return HttpResponse(open(path).read(), content_type="text/html")
except IOError:
raise Http404