Skip to content

Commit

Permalink
Render function instead of render_to_response (#111)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Asif Saifuddin Auvi authored and avelis committed Jun 10, 2016
1 parent 5447beb commit 268eed8
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions project/example_app/views.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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()})
4 changes: 2 additions & 2 deletions silk/views/profile_detail.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions silk/views/profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
4 changes: 2 additions & 2 deletions silk/views/raw.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions silk/views/request_detail.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions silk/views/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
4 changes: 2 additions & 2 deletions silk/views/sql.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
4 changes: 2 additions & 2 deletions silk/views/sql_detail.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
6 changes: 3 additions & 3 deletions silk/views/summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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))

0 comments on commit 268eed8

Please sign in to comment.