Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Converted django.views.auth.login to use load_and_render

git-svn-id: http://code.djangoproject.com/svn/django/trunk@659 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit aec3e32c7bc2a25402425f43eb054cdd25dee746 1 parent 48f0820
Adrian Holovaty authored September 22, 2005

Showing 1 changed file with 5 additions and 11 deletions. Show diff stats Hide diff stats

  1. 16  django/views/auth/login.py
16  django/views/auth/login.py
... ...
@@ -1,6 +1,6 @@
1 1
 from django.parts.auth.formfields import AuthenticationForm
2 2
 from django.core import formfields, template_loader
3  
-from django.core.extensions import DjangoContext as Context
  3
+from django.core.extensions import DjangoContext, load_and_render
4 4
 from django.models.auth import users
5 5
 from django.models.core import sites
6 6
 from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect
@@ -21,27 +21,21 @@ def login(request):
21 21
             return HttpResponseRedirect(redirect_to)
22 22
     else:
23 23
         errors = {}
24  
-    response = HttpResponse()
25 24
     request.session.set_test_cookie()
26  
-    t = template_loader.get_template('registration/login')
27  
-    c = Context(request, {
  25
+    return load_and_render('registration/login', {
28 26
         'form': formfields.FormWrapper(manipulator, request.POST, errors),
29 27
         REDIRECT_FIELD_NAME: redirect_to,
30 28
         'site_name': sites.get_current().name,
31  
-    })
32  
-    response.write(t.render(c))
33  
-    return response
  29
+    }, context_instance=DjangoContext(request))
34 30
 
35 31
 def logout(request, next_page=None):
36 32
     "Logs out the user and displays 'You are logged out' message."
37 33
     try:
38 34
         del request.session[users.SESSION_KEY]
39 35
     except KeyError:
40  
-        t = template_loader.get_template('registration/logged_out')
41  
-        c = Context(request)
42  
-        return HttpResponse(t.render(c))
  36
+        return load_and_render('registration/logged_out', context_instance=DjangoContext(request))
43 37
     else:
44  
-        # Do a redirect to this page until the session has been cleared.
  38
+        # Redirect to this page until the session has been cleared.
45 39
         return HttpResponseRedirect(next_page or request.path)
46 40
 
47 41
 def logout_then_login(request):

0 notes on commit aec3e32

Please sign in to comment.
Something went wrong with that request. Please try again.