Opened 7 years ago

Closed 7 years ago

Last modified 5 years ago

#10763 closed (duplicate)

Allow custom AuthenticationForm in django.contrib.auth login view.

Reported by: Felipe 'chronos' Prenholato Owned by: nobody
Component: contrib.auth Version: 1.1-beta
Severity: Keywords: login, forms, authentication, customization, custom
Cc: bas@… Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The idea is: allow develop to set a custom authentication form in login view without change much code.

Support of custom forms is usefull if developer use a custom form class, if plan to make more things in authentication that default form does (if for some motive he not want to write your own view) and, after all, form is better place to validate trought e-mail instead username (a common request I think).

This patch allow develop to send own authentication form to login view in urls.py and do what he wants in form.
I attach patch, a urls.py snippet and a form that I used to show example. My form use <a href="https://launchpad.net/django-form-utils">django-form-utils</a> in case to allow more customizable forms.

Attachments (3)

login_custom_form.diff (1.3 KB) - added by Felipe 'chronos' Prenholato 7 years ago.
The patch in views.py
login_custom_form-urls.py (228 bytes) - added by Felipe 'chronos' Prenholato 7 years ago.
The urls.py example.
login_custom_form-forms.py (1.7 KB) - added by Felipe 'chronos' Prenholato 7 years ago.
The form in forms.py that I using, basically a copy of AuthenticationForm

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by Felipe 'chronos' Prenholato

Attachment: login_custom_form.diff added

The patch in views.py

Changed 7 years ago by Felipe 'chronos' Prenholato

Attachment: login_custom_form-urls.py added

The urls.py example.

Changed 7 years ago by Felipe 'chronos' Prenholato

Attachment: login_custom_form-forms.py added

The form in forms.py that I using, basically a copy of AuthenticationForm

comment:1 Changed 7 years ago by Alex Gaynor

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Resolution: duplicate
Status: newclosed

Dupe #8274.

comment:2 Changed 6 years ago by Vasily Ivanov

Cc: bas@… added

comment:3 Changed 5 years ago by Jacob

milestone: 1.2

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top