Opened 6 years ago

Closed 6 years ago

#20426 closed Cleanup/optimization (fixed)

note about the AuthenticationForm API

Reported by: joel.hansson@… Owned by: nobody
Component: Documentation Version: 1.5
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes



The django.contrib.auth.forms.AuthenticationForm needs two arguments passed when creating the object in the view.

form = AuthenticationForm(request, request.POST)

I was unable to find this in the documentation anywhere.

Since I didn't know this, I thought it would take the same arguments as documented at

I initially tried that, but there was no exception raised, nothing in form.errors. However form.is_valid() still returned False.

Discovered the solution by joining #django @ freenode and was pointed to the actual source code which explained the issue.

A Note about this in the docs would have saved me an hour of hair-tearing ;)

Change History (2)

comment:1 Changed 6 years ago by FunkyBob

Something as simple as:

diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt
index e666cde..78684f9 100644
--- a/docs/topics/auth/default.txt
+++ b/docs/topics/auth/default.txt
@@ -943,6 +943,9 @@ provides several built-in forms located in :mod:`django.contrib.auth.forms`:
     A form for logging a user in.
+    Takes ``request`` as its first positional argument, which is stored on the
+    form instance for use by sub-classes.
 .. class:: PasswordChangeForm
     A form for allowing a user to change their password.

would probably suffice.

comment:2 Changed 6 years ago by Florian Apolloner <florian@…>

Resolution: fixed
Status: newclosed

In 10e397e2631f8b4c3be486dfc922a91c4512684d:

Fixed #20426 -- Added some extra info to the auth forms.

Thanks to Joel Hansson for the suggestion and Curtis Maloney for the initial

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