From 268eed8f28b674a367ebbc8a127fc25b98045058 Mon Sep 17 00:00:00 2001 From: Asif Saifuddin Auvi Date: Sat, 11 Jun 2016 02:14:59 +0600 Subject: [PATCH] Render function instead of render_to_response (#111) * replaced render_to_reponse with render function * replaced render_to_reponse with render function in views/profiling * replaced render_to_reponse with render function in views/raw * replaced render_to_reponse with render function in views/request_detail * replaced render_to_reponse with render function in views/requests * replaced render_to_reponse with render function in views/sql * replaced render_to_reponse with render function in views/sql_detail * replaced render_to_reponse with render function in views/summary * replaced render_to_reponse with render function in example project views --- project/example_app/views.py | 4 ++-- silk/views/profile_detail.py | 4 ++-- silk/views/profiling.py | 6 +++--- silk/views/raw.py | 4 ++-- silk/views/request_detail.py | 4 ++-- silk/views/requests.py | 6 +++--- silk/views/sql.py | 4 ++-- silk/views/sql_detail.py | 4 ++-- silk/views/summary.py | 6 +++--- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/project/example_app/views.py b/project/example_app/views.py index dd5e741e..1ea76d91 100644 --- a/project/example_app/views.py +++ b/project/example_app/views.py @@ -1,7 +1,7 @@ from time import sleep # Create your views here. -from django.shortcuts import render_to_response +from django.shortcuts import render from example_app import models from silk.profiling.profiler import silk_profile @@ -13,4 +13,4 @@ def do_something_long(): with silk_profile(name='Why do this take so long?'): do_something_long() - return render_to_response('example_app/index.html', {'blinds': models.Blind.objects.all()}) + return render('example_app/index.html', {'blinds': models.Blind.objects.all()}) diff --git a/silk/views/profile_detail.py b/silk/views/profile_detail.py index 0428b886..d61ae366 100644 --- a/silk/views/profile_detail.py +++ b/silk/views/profile_detail.py @@ -1,4 +1,4 @@ -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.decorators import method_decorator from django.views.generic import View from silk.auth import login_possibly_required, permissions_possibly_required @@ -36,4 +36,4 @@ def get(self, request, *_, **kwargs): else: raise e - return render_to_response('silk/profile_detail.html', context) + return render('silk/profile_detail.html', context) diff --git a/silk/views/profiling.py b/silk/views/profiling.py index bba1c4f9..d1d660e6 100644 --- a/silk/views/profiling.py +++ b/silk/views/profiling.py @@ -3,7 +3,7 @@ except ImportError: from django.core.context_processors import csrf from django.db.models import Count, Sum -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.decorators import method_decorator from django.views.generic import View from silk.auth import login_possibly_required, permissions_possibly_required @@ -127,11 +127,11 @@ def _create_context(self, request, *args, **kwargs): @method_decorator(permissions_possibly_required) def get(self, request, *args, **kwargs): - return render_to_response('silk/profiling.html', self._create_context(request, *args, **kwargs)) + return render('silk/profiling.html', self._create_context(request, *args, **kwargs)) @method_decorator(login_possibly_required) @method_decorator(permissions_possibly_required) def post(self, request): filters = filters_from_request(request) request.session[self.session_key_profile_filters] = {ident: f.as_dict() for ident, f in filters.items()} - return render_to_response('silk/profiling.html', self._create_context(request)) + return render('silk/profiling.html', self._create_context(request)) diff --git a/silk/views/raw.py b/silk/views/raw.py index c5ca4254..5b3f2577 100644 --- a/silk/views/raw.py +++ b/silk/views/raw.py @@ -1,5 +1,5 @@ from django.http import HttpResponse -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.decorators import method_decorator from django.views.generic import View from silk.auth import login_possibly_required, permissions_possibly_required @@ -23,7 +23,7 @@ def get(self, request, request_id): elif typ == 'response': Logger.debug(silk_request.response.raw_body_decoded) body = silk_request.response.raw_body_decoded if subtyp == 'raw' else silk_request.response.body - return render_to_response('silk/raw.html', { + return render('silk/raw.html', { 'body': body }) else: diff --git a/silk/views/request_detail.py b/silk/views/request_detail.py index 23c91521..ffd50f24 100644 --- a/silk/views/request_detail.py +++ b/silk/views/request_detail.py @@ -1,6 +1,6 @@ import json -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.decorators import method_decorator from django.views.generic import View from silk.auth import login_possibly_required, permissions_possibly_required @@ -39,4 +39,4 @@ def get(self, request, request_id): content_type=silk_request.content_type), 'request': request } - return render_to_response('silk/request.html', context) + return render('silk/request.html', context) diff --git a/silk/views/requests.py b/silk/views/requests.py index 5eadd68e..ae2c9e55 100644 --- a/silk/views/requests.py +++ b/silk/views/requests.py @@ -5,7 +5,7 @@ from django.template.context_processors import csrf from django.db.models import Sum -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.decorators import method_decorator from django.views.generic import View from silk.profiling.dynamic import _get_module @@ -121,11 +121,11 @@ def _create_context(self, request): @method_decorator(login_possibly_required) @method_decorator(permissions_possibly_required) def get(self, request): - return render_to_response('silk/requests.html', self._create_context(request)) + return render('silk/requests.html', self._create_context(request)) @method_decorator(login_possibly_required) @method_decorator(permissions_possibly_required) def post(self, request): filters = filters_from_request(request) request.session[self.session_key_request_filters] = {ident: f.as_dict() for ident, f in filters.items()} - return render_to_response('silk/requests.html', self._create_context(request)) + return render('silk/requests.html', self._create_context(request)) diff --git a/silk/views/sql.py b/silk/views/sql.py index 8965ea68..1d83e582 100644 --- a/silk/views/sql.py +++ b/silk/views/sql.py @@ -1,4 +1,4 @@ -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.decorators import method_decorator from django.views.generic import View from silk.auth import login_possibly_required, permissions_possibly_required @@ -33,4 +33,4 @@ def get(self, request, *_, **kwargs): raise KeyError('no profile_id or request_id') # noinspection PyUnboundLocalVariable context['items'] = page - return render_to_response('silk/sql.html', context) + return render('silk/sql.html', context) diff --git a/silk/views/sql_detail.py b/silk/views/sql_detail.py index 3fadc051..c6b90ad2 100644 --- a/silk/views/sql_detail.py +++ b/silk/views/sql_detail.py @@ -1,7 +1,7 @@ import re from django.core.exceptions import PermissionDenied -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.decorators import method_decorator from django.utils.safestring import mark_safe from django.views.generic import View @@ -84,4 +84,4 @@ def get(self, request, *_, **kwargs): actual_line, code = _code(file_path, line_num) context['code'] = code context['actual_line'] = actual_line - return render_to_response('silk/sql_detail.html', context) + return render('silk/sql_detail.html', context) diff --git a/silk/views/summary.py b/silk/views/summary.py index d2a1a07c..669be2a6 100644 --- a/silk/views/summary.py +++ b/silk/views/summary.py @@ -5,7 +5,7 @@ from django.template.context_processors import csrf from django.db.models import Avg, Count, Sum, Max -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.decorators import method_decorator from django.views.generic import View @@ -81,11 +81,11 @@ def _create_context(self, request): @method_decorator(permissions_possibly_required) def get(self, request): c = self._create_context(request) - return render_to_response('silk/summary.html', c) + return render('silk/summary.html', c) @method_decorator(login_possibly_required) @method_decorator(permissions_possibly_required) def post(self, request): filters = filters_from_request(request) request.session[self.filters_key] = {ident: f.as_dict() for ident, f in filters.items()} - return render_to_response('silk/summary.html', self._create_context(request)) + return render('silk/summary.html', self._create_context(request))