Repository: django-cms/django-filer

Issue:
Use ``render`` instead of ``render_to_response``
See https://github.com/stefanfoulis/django-filer/pull/502#issuecomment-94064090



Discussion:

Resolving patch:
diff --git a/filer/admin/folderadmin.py b/filer/admin/folderadmin.py
--- a/filer/admin/folderadmin.py
+++ b/filer/admin/folderadmin.py
@@ -4,7 +4,7 @@
 import os
 import re
 
-from django import forms, template
+from django import forms
 from django.conf import settings as django_settings
 from django.contrib import messages
 from django.contrib.admin import helpers
@@ -15,8 +15,7 @@
 from django.core.urlresolvers import reverse
 from django.db import router, models
 from django.http import HttpResponseRedirect, HttpResponse
-from django.shortcuts import render_to_response, get_object_or_404
-from django.template import RequestContext
+from django.shortcuts import render, get_object_or_404
 
 try:
     from django.utils.encoding import force_text
@@ -379,7 +378,8 @@ def directory_listing(self, request, folder_id=None, viewtype=None):
             paginated_items = paginator.page(1)
         except EmptyPage:
             paginated_items = paginator.page(paginator.num_pages)
-        return render_to_response(
+        return render(
+            request,
             self.directory_listing_template,
             {
                 'folder': folder,
@@ -411,7 +411,7 @@ def directory_listing(self, request, folder_id=None, viewtype=None):
                 'can_make_folder': request.user.is_superuser or \
                         (folder.is_root and settings.FILER_ALLOW_REGULAR_USERS_TO_ADD_ROOT_FOLDERS) or \
                         permissions.get("has_add_children_permission"),
-        }, context_instance=RequestContext(request))
+        })
 
     def filter_folder(self, qs, terms=[]):
         for term in terms:
@@ -717,9 +717,7 @@ def delete_files_or_folders(self, request, files_queryset, folders_queryset):
         }
 
         # Display the destination folder selection page
-        return render_to_response([
-            "admin/filer/delete_selected_files_confirmation.html"
-        ], context, context_instance=template.RequestContext(request))
+        return render(request, "admin/filer/delete_selected_files_confirmation.html", context)
 
     delete_files_or_folders.short_description = ugettext_lazy("Delete selected files and/or folders")
 
@@ -863,9 +861,7 @@ def move_files_and_folders(self, request, files_queryset, folders_queryset):
         }
 
         # Display the destination folder selection page
-        return render_to_response([
-            "admin/filer/folder/choose_move_destination.html"
-        ], context, context_instance=template.RequestContext(request))
+        return render(request, "admin/filer/folder/choose_move_destination.html", context)
 
     move_files_and_folders.short_description = ugettext_lazy("Move selected files and/or folders")
 
@@ -947,9 +943,7 @@ def rename_files(self, request, files_queryset, folders_queryset):
         }
 
         # Display the rename format selection page
-        return render_to_response([
-            "admin/filer/folder/choose_rename_format.html"
-        ], context, context_instance=template.RequestContext(request))
+        return render(request, "admin/filer/folder/choose_rename_format.html", context)
 
     rename_files.short_description = ugettext_lazy("Rename files")
 
@@ -1078,9 +1072,7 @@ def copy_files_and_folders(self, request, files_queryset, folders_queryset):
         }
 
         # Display the destination folder selection page
-        return render_to_response([
-            "admin/filer/folder/choose_copy_destination.html"
-        ], context, context_instance=template.RequestContext(request))
+        return render(request, "admin/filer/folder/choose_copy_destination.html", context)
 
     copy_files_and_folders.short_description = ugettext_lazy("Copy selected files and/or folders")
 
@@ -1200,8 +1192,6 @@ def resize_images(self, request, files_queryset, folders_queryset):
         }
 
         # Display the resize options page
-        return render_to_response([
-            "admin/filer/folder/choose_images_resize_options.html"
-        ], context, context_instance=template.RequestContext(request))
+        return render(request, "admin/filer/folder/choose_images_resize_options.html", context)
 
     resize_images.short_description = ugettext_lazy("Resize selected images")
diff --git a/filer/views.py b/filer/views.py
--- a/filer/views.py
+++ b/filer/views.py
@@ -6,8 +6,7 @@
 from django.contrib.auth.decorators import login_required
 from django.core.exceptions import PermissionDenied
 from django.http import HttpResponseRedirect
-from django.shortcuts import render_to_response
-from django.template import RequestContext
+from django.shortcuts import render
 from django.utils import six
 from django.utils.translation import ugettext_lazy as _
 from .models import Folder, Image, Clipboard, tools, FolderRoot
@@ -61,22 +60,22 @@ def _userperms(item, request):
 def edit_folder(request, folder_id):
     # TODO: implement edit_folder view
     folder = None
-    return render_to_response('admin/filer/folder/folder_edit.html', {
+    return render(request, 'admin/filer/folder/folder_edit.html', {
         'folder': folder,
         'is_popup': popup_status(request),
         'select_folder': selectfolder_status(request),
-    }, context_instance=RequestContext(request))
+    })
 
 
 @login_required
 def edit_image(request, folder_id):
     # TODO: implement edit_image view
     folder = None
-    return render_to_response('filer/image_edit.html', {
+    return render(request, 'filer/image_edit.html', {
         'folder': folder,
         'is_popup': popup_status(request),
         'select_folder': selectfolder_status(request),
-    }, context_instance=RequestContext(request))
+    })
 
 
 @login_required
@@ -108,16 +107,15 @@ def make_folder(request, folder_id=None):
                 new_folder.parent = folder
                 new_folder.owner = request.user
                 new_folder.save()
-                return render_to_response('admin/filer/dismiss_popup.html',
-                                          context_instance=RequestContext(request))
+                return render(request, 'admin/filer/dismiss_popup.html')
     else:
         new_folder_form = NewFolderForm()
-    return render_to_response('admin/filer/folder/new_folder_form.html', {
+    return render(request, 'admin/filer/folder/new_folder_form.html', {
         'opts': Folder._meta,
         'new_folder_form': new_folder_form,
         'is_popup': popup_status(request),
         'select_folder': selectfolder_status(request),
-    }, context_instance=RequestContext(request))
+    })
 
 
 class UploadFileForm(forms.ModelForm):
@@ -128,11 +126,11 @@ class Meta:
 
 @login_required
 def upload(request):
-    return render_to_response('filer/upload.html', {
+    return render(request, 'filer/upload.html', {
                     'title': 'Upload files',
                     'is_popup': popup_status(request),
                     'select_folder': selectfolder_status(request),
-                    }, context_instance=RequestContext(request))
+                    })
 
 
 @login_required


Test patch: