From 076175e9134ecd47339c9912d0ebf1e8948344da Mon Sep 17 00:00:00 2001 From: Samuel Gaist <samuel.gaist@idiap.ch> Date: Wed, 7 Mar 2018 15:17:36 +0100 Subject: [PATCH] [statistics][views] Moved from render_to_response to render render_to_response is deprecated in Django 2.0 and render has been available since 1.3. It's shorter to write and avoids the writing of context_instance=RequestContext(request) in each of its call. --- beat/web/statistics/views.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/beat/web/statistics/views.py b/beat/web/statistics/views.py index 616fdcb5e..f35426c98 100644 --- a/beat/web/statistics/views.py +++ b/beat/web/statistics/views.py @@ -31,14 +31,14 @@ import itertools import simplejson -from django.shortcuts import render_to_response -from django.template import RequestContext +from django.shortcuts import render from django.contrib.auth.decorators import login_required from django.http import HttpResponseForbidden from django.db.models import Sum from .models import HourlyStatistics + def calculate_totals(): """Caculates all totals required by the statistics display""" @@ -269,11 +269,11 @@ def statistics(request): if not(request.user.is_superuser): return HttpResponseForbidden() - return render_to_response('statistics/statistics.html', - dict( - totals=calculate_totals(), - hourly_chart_data=hourly_charts(), - daily_chart_data=daily_charts(), - weekly_chart_data=weekly_charts(), - ), - context_instance=RequestContext(request)) + return render(request, + 'statistics/statistics.html', + dict( + totals=calculate_totals(), + hourly_chart_data=hourly_charts(), + daily_chart_data=daily_charts(), + weekly_chart_data=weekly_charts(), + )) -- GitLab