示例#1
0
    def render_model_preview(self, request):
        try:
            content_type_id = int(request.GET["content_type"])
            object_id = int(request.GET["object_id"])
        except (ValueError, KeyError):
            return HttpResponseBadRequest()

        try:
            content_type = ContentType.objects.get(pk=content_type_id)
            model = content_type.model_class()
            result = model.objects.get(pk=object_id)
        except ObjectDoesNotExist:
            return HttpResponseNotFound()

        template = request.GET.get("template", "preview")
        return HttpResponse(render_model(result, template))
示例#2
0
 def render_model_preview(self, request):
     type = ContentType.objects.get(pk=request.GET["content_type"])
     model = type.model_class().objects.get(pk=request.GET["object_id"])
     template = request.GET.get("template", "preview")
     return HttpResponse(render_model(model, template))
示例#3
0
 def render_model_preview(self, request):
     type = ContentType.objects.get(pk=request.GET["content_type"])
     model = type.model_class().objects.get(pk=request.GET["object_id"])
     template = request.GET.get("template", "preview")
     return HttpResponse(render_model(model, template))