From b429031394195e28e78c35dff01fedf170df66b7 Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Wed, 20 Jul 2016 07:31:52 -0400 Subject: [PATCH 1/2] Use render() shortcut for UI. Removes RendererContext 1.10 deprecation warning. --- rest_framework_swagger/renderers.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) 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 = { From 47b40b2970c13abf0ea68f6f4544a92f56a9028c Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Wed, 20 Jul 2016 07:36:43 -0400 Subject: [PATCH 2/2] Include license, readme and exclude bytecode. --- MANIFEST.in | 7 +++++++ 1 file changed, 7 insertions(+) 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 *