Use render instead of render_to_response
authorDiane Trout <diane@ghic.org>
Wed, 1 Jun 2016 23:56:13 +0000 (16:56 -0700)
committerDiane Trout <diane@ghic.org>
Fri, 24 Jun 2016 22:55:58 +0000 (15:55 -0700)
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.

experiments/views.py
inventory/views.py

index c71077d1819aaf1de9795f4e39c02cda1d74bb40..1cce2d949015686447aa415059b92465def251d1 100644 (file)
@@ -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 = '<h2>Exp Track Details Page</h2>'
     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)
+
index d9dda8dd34fcda457c74b17c57f5eec0826c07e5..0dae606257638e4ae5a57242e6b0ba3f69c415c3 100644 (file)
@@ -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):