Ticket #10763: login_custom_form.diff

File login_custom_form.diff, 1.3 KB (added by Felipe 'chronos' Prenholato, 16 years ago)

The patch in views.py

  • django/contrib/auth/views.py

     
    1414from django.contrib.auth.models import User
    1515from django.views.decorators.cache import never_cache
    1616
    17 def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME):
     17def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, form_object=AuthenticationForm):
    1818    "Displays the login form and handles the login action."
    1919    redirect_to = request.REQUEST.get(redirect_field_name, '')
    2020    if request.method == "POST":
    21         form = AuthenticationForm(data=request.POST)
     21        form = form_object(data=request.POST)
    2222        if form.is_valid():
    2323            # Light security check -- make sure redirect_to isn't garbage.
    2424            if not redirect_to or '//' in redirect_to or ' ' in redirect_to:
     
    2929                request.session.delete_test_cookie()
    3030            return HttpResponseRedirect(redirect_to)
    3131    else:
    32         form = AuthenticationForm(request)
     32        form = form_object(request)
    3333    request.session.set_test_cookie()
    3434    if Site._meta.installed:
    3535        current_site = Site.objects.get_current()
Back to Top