Ticket #4225: contrib.auth.views.login.patch

File contrib.auth.views.login.patch, 1.1 KB (added by mconte, 18 years ago)

Patch to solve login() site table issue

  • contrib/auth/views.py

     
    88from django.contrib.auth.decorators import login_required
    99from django.contrib.auth import REDIRECT_FIELD_NAME
    1010
     11class GenericSite(object):
     12    domain = 'example.com'
     13    name = 'my site'
     14
    1115def login(request, template_name='registration/login.html'):
    1216    "Displays the login form and handles the login action."
    1317    manipulator = AuthenticationForm(request)
     
    2630    else:
    2731        errors = {}
    2832    request.session.set_test_cookie()
     33    if Site._meta.installed:
     34        site_obj = Site.objects.get_current().name
     35    else:
     36        site_obj = GenericSite()
    2937    return render_to_response(template_name, {
    3038        'form': oldforms.FormWrapper(manipulator, request.POST, errors),
    3139        REDIRECT_FIELD_NAME: redirect_to,
    32         'site_name': Site.objects.get_current().name,
     40        'site_name': site_obj,
    3341    }, context_instance=RequestContext(request))
    3442
    3543def logout(request, next_page=None, template_name='registration/logged_out.html'):
Back to Top