Commit 664a8ae35bfc9a9df21719dd8f9e6cc77b345aea
1 parent
de9071c5
Replaced render_to_response by render shortcut
Showing
3 changed files
with
8 additions
and
29 deletions
| @@ -4,8 +4,7 @@ from django import http | @@ -4,8 +4,7 @@ from django import http | ||
| 4 | from django.conf import settings | 4 | from django.conf import settings |
| 5 | from django.core.exceptions import ObjectDoesNotExist, ValidationError | 5 | from django.core.exceptions import ObjectDoesNotExist, ValidationError |
| 6 | from django.db import models | 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 | from django.template.loader import render_to_string | 8 | from django.template.loader import render_to_string |
| 10 | from django.utils.html import escape | 9 | from django.utils.html import escape |
| 11 | from django.views.decorators.csrf import csrf_protect | 10 | from django.views.decorators.csrf import csrf_protect |
| @@ -98,13 +97,11 @@ def post_comment(request, next=None, using=None): | @@ -98,13 +97,11 @@ def post_comment(request, next=None, using=None): | ||
| 98 | "comments/%s/preview.html" % model._meta.app_label, | 97 | "comments/%s/preview.html" % model._meta.app_label, |
| 99 | "comments/preview.html", | 98 | "comments/preview.html", |
| 100 | ] | 99 | ] |
| 101 | - return render_to_response( | ||
| 102 | - template_list, { | 100 | + return render(request, template_list, { |
| 103 | "comment": form.data.get("comment", ""), | 101 | "comment": form.data.get("comment", ""), |
| 104 | "form": form, | 102 | "form": form, |
| 105 | "next": data.get("next", next), | 103 | "next": data.get("next", next), |
| 106 | }, | 104 | }, |
| 107 | - RequestContext(request, {}) | ||
| 108 | ) | 105 | ) |
| 109 | 106 | ||
| 110 | # Otherwise create the comment | 107 | # Otherwise create the comment |
| 1 | from __future__ import absolute_import | 1 | from __future__ import absolute_import |
| 2 | 2 | ||
| 3 | -from django import template | ||
| 4 | from django.conf import settings | 3 | from django.conf import settings |
| 5 | from django.contrib.auth.decorators import login_required, permission_required | 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 | from django.views.decorators.csrf import csrf_protect | 6 | from django.views.decorators.csrf import csrf_protect |
| 8 | 7 | ||
| 9 | import django_comments | 8 | import django_comments |
| @@ -32,11 +31,7 @@ def flag(request, comment_id, next=None): | @@ -32,11 +31,7 @@ def flag(request, comment_id, next=None): | ||
| 32 | 31 | ||
| 33 | # Render a form on GET | 32 | # Render a form on GET |
| 34 | else: | 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 | @csrf_protect | 37 | @csrf_protect |
| @@ -62,11 +57,7 @@ def delete(request, comment_id, next=None): | @@ -62,11 +57,7 @@ def delete(request, comment_id, next=None): | ||
| 62 | 57 | ||
| 63 | # Render a form on GET | 58 | # Render a form on GET |
| 64 | else: | 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 | @csrf_protect | 63 | @csrf_protect |
| @@ -92,11 +83,7 @@ def approve(request, comment_id, next=None): | @@ -92,11 +83,7 @@ def approve(request, comment_id, next=None): | ||
| 92 | 83 | ||
| 93 | # Render a form on GET | 84 | # Render a form on GET |
| 94 | else: | 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 | # The following functions actually perform the various flag/aprove/delete | 89 | # The following functions actually perform the various flag/aprove/delete |
| @@ -10,8 +10,7 @@ except ImportError: # Python 2 | @@ -10,8 +10,7 @@ except ImportError: # Python 2 | ||
| 10 | from urllib import urlencode | 10 | from urllib import urlencode |
| 11 | 11 | ||
| 12 | from django.http import HttpResponseRedirect | 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 | from django.core.exceptions import ObjectDoesNotExist | 14 | from django.core.exceptions import ObjectDoesNotExist |
| 16 | from django.utils.http import is_safe_url | 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,11 +57,7 @@ def confirmation_view(template, doc="Display a confirmation view."): | ||
| 58 | comment = django_comments.get_model().objects.get(pk=request.GET['c']) | 57 | comment = django_comments.get_model().objects.get(pk=request.GET['c']) |
| 59 | except (ObjectDoesNotExist, ValueError): | 58 | except (ObjectDoesNotExist, ValueError): |
| 60 | pass | 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 | confirmed.__doc__ = textwrap.dedent("""\ | 62 | confirmed.__doc__ = textwrap.dedent("""\ |
| 68 | %s | 63 | %s |
Please
register
or
login
to post a comment