Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Changed django.contrib.auth.views.login to use RequestSite if the sit…

…es framework is not installed -- i.e., the sites framework is no longer required to use this view. See also [5654]

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5885 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 6aae9b2aa413b16e77e864ac69aa616aa7e2d969 1 parent 9b99a60
Adrian Holovaty authored August 14, 2007
10  django/contrib/auth/views.py
@@ -3,7 +3,7 @@
3 3
 from django import oldforms
4 4
 from django.shortcuts import render_to_response
5 5
 from django.template import RequestContext
6  
-from django.contrib.sites.models import Site
  6
+from django.contrib.sites.models import Site, RequestSite
7 7
 from django.http import HttpResponseRedirect
8 8
 from django.contrib.auth.decorators import login_required
9 9
 from django.contrib.auth import REDIRECT_FIELD_NAME
@@ -27,10 +27,16 @@ def login(request, template_name='registration/login.html'):
27 27
     else:
28 28
         errors = {}
29 29
     request.session.set_test_cookie()
  30
+
  31
+    if Site._meta.installed:
  32
+        current_site = Site.objects.get_current()
  33
+    else:
  34
+        current_site = RequestSite(self.request)
  35
+
30 36
     return render_to_response(template_name, {
31 37
         'form': oldforms.FormWrapper(manipulator, request.POST, errors),
32 38
         REDIRECT_FIELD_NAME: redirect_to,
33  
-        'site_name': Site.objects.get_current().name,
  39
+        'site_name': current_site.name,
34 40
     }, context_instance=RequestContext(request))
35 41
 
36 42
 def logout(request, next_page=None, template_name='registration/logged_out.html'):
5  docs/authentication.txt
@@ -436,7 +436,10 @@ template context variables:
436 436
     * ``next``: The URL to redirect to after successful login. This may contain
437 437
       a query string, too.
438 438
     * ``site_name``: The name of the current ``Site``, according to the
439  
-      ``SITE_ID`` setting. See the `site framework docs`_.
  439
+      ``SITE_ID`` setting. If you're using the Django development version and
  440
+      you don't have the site framework installed, this will be set to the
  441
+      value of ``request.META['SERVER_NAME']``. For more on sites, see the
  442
+      `site framework docs`_.
440 443
 
441 444
 If you'd prefer not to call the template ``registration/login.html``, you can
442 445
 pass the ``template_name`` parameter via the extra arguments to the view in

0 notes on commit 6aae9b2

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