Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

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: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 9b99a60 commit 6aae9b2aa413b16e77e864ac69aa616aa7e2d969 @adrianholovaty adrianholovaty committed
Showing with 12 additions and 3 deletions.
  1. +8 −2 django/contrib/auth/
  2. +4 −1 docs/authentication.txt
10 django/contrib/auth/
@@ -3,7 +3,7 @@
from django import oldforms
from django.shortcuts import render_to_response
from django.template import RequestContext
-from django.contrib.sites.models import Site
+from django.contrib.sites.models import Site, RequestSite
from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django.contrib.auth import REDIRECT_FIELD_NAME
@@ -27,10 +27,16 @@ def login(request, template_name='registration/login.html'):
errors = {}
+ if Site._meta.installed:
+ current_site = Site.objects.get_current()
+ else:
+ current_site = RequestSite(self.request)
return render_to_response(template_name, {
'form': oldforms.FormWrapper(manipulator, request.POST, errors),
- 'site_name': Site.objects.get_current().name,
+ 'site_name':,
}, context_instance=RequestContext(request))
def logout(request, next_page=None, template_name='registration/logged_out.html'):
5 docs/authentication.txt
@@ -436,7 +436,10 @@ template context variables:
* ``next``: The URL to redirect to after successful login. This may contain
a query string, too.
* ``site_name``: The name of the current ``Site``, according to the
- ``SITE_ID`` setting. See the `site framework docs`_.
+ ``SITE_ID`` setting. If you're using the Django development version and
+ you don't have the site framework installed, this will be set to the
+ value of ``request.META['SERVER_NAME']``. For more on sites, see the
+ `site framework docs`_.
If you'd prefer not to call the template ``registration/login.html``, you can
pass the ``template_name`` parameter via the extra arguments to the view in

0 comments on commit 6aae9b2

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