Opened 12 years ago
Closed 12 years ago
#20426 closed Cleanup/optimization (fixed)
note about the AuthenticationForm API
| Reported by: | 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 |
Description
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 https://docs.djangoproject.com/en/1.5/topics/forms/#using-a-form-in-a-view
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 by , 12 years ago
comment:2 by , 12 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
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.