From: Diane Trout Date: Wed, 1 Jun 2016 23:56:13 +0000 (-0700) Subject: Use render instead of render_to_response X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=3cb764720e59ccfb507b8ff769d1548d02698e9f Use render instead of render_to_response Somtimes I needed to use context_instance=RequestContext(request) in my templates, and that parameter was depreacted for render_to_response. It seemed easier to just universally switch to the newer render() call which directly takes the request object. --- diff --git a/experiments/views.py b/experiments/views.py index c71077d..1cce2d9 100644 --- a/experiments/views.py +++ b/experiments/views.py @@ -26,13 +26,13 @@ from samples.models import HTSUser def index(request): all_runs = SequencingRun.objects.order_by('-run_start_time') - return render_to_response('experiments/index.html',{'data_run_list': all_runs}) + return render(request, 'experiments/index.html',{'data_run_list': all_runs}) def detail(request, run_folder): html_str = '

Exp Track Details Page

' html_str += 'Run Folder: '+run_folder r = get_object_or_404(SequencingRun,run_folder=run_folder) - return render_to_response('experiments/detail.html',{'run_f': r}) + return render(request, 'experiments/detail.html',{'run_f': r}) def makeFCSheet(request,fcid): # get Flowcell by input fcid @@ -43,7 +43,7 @@ def makeFCSheet(request,fcid): except ObjectDoesNotExist: pass lanes = ['1','2','3','4','5','6','7','8'] - return render_to_response('experiments/flowcellSheet.html',{'fc': rec}) + return render(request, 'experiments/flowcellSheet.html',{'fc': rec}) @user_passes_test(lambda u: u.is_staff) @@ -145,8 +145,7 @@ def flowcell_detail(request, flowcell_id, lane_number=None): {'flowcell': fc, 'lanes': lanes}) - return render_to_response('experiments/flowcell_detail.html', - context) + return render(request, 'experiments/flowcell_detail.html', context) def flowcell_lane_detail(request, lane_pk): lane = get_object_or_404(Lane, id=lane_pk) @@ -166,8 +165,7 @@ def flowcell_lane_detail(request, lane_pk): 'flowcell': lane.flowcell, 'filtered_sequencingruns': sequencingruns}) - return render_to_response('experiments/flowcell_lane_detail.html', - context) + return render(request, 'experiments/flowcell_lane_detail.html', context) def read_result_file(self, key): """Return the contents of filename if everything is approved @@ -189,7 +187,7 @@ def sequencer(request, sequencer_id): sequencer = get_object_or_404(Sequencer, id=sequencer_id) context = RequestContext(request, {'sequencer': sequencer}) - return render_to_response('experiments/sequencer.html', context) + return render(request, 'experiments/sequencer.html', context) def lanes_for(request, username=None): @@ -215,8 +213,5 @@ def lanes_for(request, username=None): context = {'lanes': fcl, 'title': 'Lane Index'} - return render_to_response( - 'samples/lanes_for.html', - context, - context_instance=RequestContext(request) - ) + return render(request, 'samples/lanes_for.html', context) + diff --git a/inventory/views.py b/inventory/views.py index d9dda8d..0dae606 100644 --- a/inventory/views.py +++ b/inventory/views.py @@ -4,7 +4,7 @@ from django.conf import settings from django.contrib.auth.decorators import login_required from django.core.exceptions import ObjectDoesNotExist from django.http import HttpResponse, HttpResponseRedirect -from django.shortcuts import render_to_response +from django.shortcuts import render from django.template import RequestContext, Template from django.template.loader import get_template @@ -151,9 +151,9 @@ def all_index(request): } context_dict.update(INVENTORY_CONTEXT_DEFAULTS) - return render_to_response('inventory/inventory_all_index.html', - context_dict, - context_instance=RequestContext(request)) + return render(request, + 'inventory/inventory_all_index.html', + context_dict) @login_required def index(request): @@ -173,9 +173,9 @@ def index(request): 'page_name': 'Inventory Index' } context_dict.update(INVENTORY_CONTEXT_DEFAULTS) - return render_to_response('inventory/inventory_index.html', - context_dict, - context_instance=RequestContext(request)) + return render(request, + 'inventory/inventory_index.html', + context_dict) @login_required def itemtype_index(request, name): @@ -201,9 +201,9 @@ def itemtype_index(request, name): } context_dict.update(INVENTORY_CONTEXT_DEFAULTS) - return render_to_response('inventory/inventory_itemtype_index.html', - context_dict, - context_instance=RequestContext(request)) + return render(request, + 'inventory/inventory_itemtype_index.html', + context_dict) @login_required @@ -239,13 +239,9 @@ def item_summary_by_uuid(request, uuid, msg='', item=None): } context_dict.update(INVENTORY_CONTEXT_DEFAULTS) - return render_to_response('inventory/inventory_summary.html', - context_dict, - context_instance=RequestContext(request)) - - - - + return render(request, + 'inventory/inventory_summary.html', + context_dict) def __expand_context(context, item):