Commit 664a8ae35bfc9a9df21719dd8f9e6cc77b345aea

Authored by Claude Paroz
1 parent de9071c5

Replaced render_to_response by render shortcut

... ... @@ -4,8 +4,7 @@ from django import http
4 4 from django.conf import settings
5 5 from django.core.exceptions import ObjectDoesNotExist, ValidationError
6 6 from django.db import models
7   -from django.shortcuts import render_to_response
8   -from django.template import RequestContext
  7 +from django.shortcuts import render
9 8 from django.template.loader import render_to_string
10 9 from django.utils.html import escape
11 10 from django.views.decorators.csrf import csrf_protect
... ... @@ -98,13 +97,11 @@ def post_comment(request, next=None, using=None):
98 97 "comments/%s/preview.html" % model._meta.app_label,
99 98 "comments/preview.html",
100 99 ]
101   - return render_to_response(
102   - template_list, {
  100 + return render(request, template_list, {
103 101 "comment": form.data.get("comment", ""),
104 102 "form": form,
105 103 "next": data.get("next", next),
106 104 },
107   - RequestContext(request, {})
108 105 )
109 106
110 107 # Otherwise create the comment
... ...
1 1 from __future__ import absolute_import
2 2
3   -from django import template
4 3 from django.conf import settings
5 4 from django.contrib.auth.decorators import login_required, permission_required
6   -from django.shortcuts import get_object_or_404, render_to_response
  5 +from django.shortcuts import get_object_or_404, render
7 6 from django.views.decorators.csrf import csrf_protect
8 7
9 8 import django_comments
... ... @@ -32,11 +31,7 @@ def flag(request, comment_id, next=None):
32 31
33 32 # Render a form on GET
34 33 else:
35   - return render_to_response(
36   - 'comments/flag.html',
37   - {'comment': comment, "next": next},
38   - template.RequestContext(request)
39   - )
  34 + return render(request, 'comments/flag.html', {'comment': comment, "next": next})
40 35
41 36
42 37 @csrf_protect
... ... @@ -62,11 +57,7 @@ def delete(request, comment_id, next=None):
62 57
63 58 # Render a form on GET
64 59 else:
65   - return render_to_response(
66   - 'comments/delete.html',
67   - {'comment': comment, "next": next},
68   - template.RequestContext(request)
69   - )
  60 + return render(request, 'comments/delete.html', {'comment': comment, "next": next})
70 61
71 62
72 63 @csrf_protect
... ... @@ -92,11 +83,7 @@ def approve(request, comment_id, next=None):
92 83
93 84 # Render a form on GET
94 85 else:
95   - return render_to_response(
96   - 'comments/approve.html',
97   - {'comment': comment, "next": next},
98   - template.RequestContext(request)
99   - )
  86 + return render(request, 'comments/approve.html', {'comment': comment, "next": next})
100 87
101 88
102 89 # The following functions actually perform the various flag/aprove/delete
... ...
... ... @@ -10,8 +10,7 @@ except ImportError: # Python 2
10 10 from urllib import urlencode
11 11
12 12 from django.http import HttpResponseRedirect
13   -from django.shortcuts import render_to_response, resolve_url
14   -from django.template import RequestContext
  13 +from django.shortcuts import render, resolve_url
15 14 from django.core.exceptions import ObjectDoesNotExist
16 15 from django.utils.http import is_safe_url
17 16
... ... @@ -58,11 +57,7 @@ def confirmation_view(template, doc="Display a confirmation view."):
58 57 comment = django_comments.get_model().objects.get(pk=request.GET['c'])
59 58 except (ObjectDoesNotExist, ValueError):
60 59 pass
61   - return render_to_response(
62   - template,
63   - {'comment': comment},
64   - context_instance=RequestContext(request)
65   - )
  60 + return render(request, template, {'comment': comment})
66 61
67 62 confirmed.__doc__ = textwrap.dedent("""\
68 63 %s
... ...
Please register or login to post a comment