diff --git a/MANIFEST.in b/MANIFEST.in index 4edcecc0..e2cfbde8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,9 @@ +include README.md +include LICENSE + +global-exclude __pycache__ +global-exclude *.pyc +global-exclude *.pyo + recursive-include rest_framework_swagger/static * recursive-include rest_framework_swagger/templates * diff --git a/rest_framework_swagger/renderers.py b/rest_framework_swagger/renderers.py index 09007454..2fd4104e 100644 --- a/rest_framework_swagger/renderers.py +++ b/rest_framework_swagger/renderers.py @@ -1,7 +1,6 @@ from coreapi.compat import force_bytes from django.conf import settings -from django.shortcuts import resolve_url -from django.template import loader, RequestContext +from django.shortcuts import render, resolve_url from openapi_codec import OpenAPICodec from rest_framework.renderers import BaseRenderer import simplejson as json @@ -31,18 +30,18 @@ class SwaggerUIRenderer(BaseRenderer): charset = 'utf-8' def render(self, data, accepted_media_type=None, renderer_context=None): - context = self.get_context(renderer_context) - template = loader.get_template(self.template) - - return template.render(context) - - def get_context(self, renderer_context): + self.set_context(renderer_context) + return render( + renderer_context['request'], + self.template, + renderer_context + ) + + def set_context(self, renderer_context): renderer_context['USE_SESSION_AUTH'] = \ swagger_settings.USE_SESSION_AUTH self.set_session_auth_urls(renderer_context) - return RequestContext(renderer_context['request'], renderer_context) - def set_session_auth_urls(self, renderer_context): path = renderer_context['request'].path urls = {