Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Note `authenticate` usage with custom user model. #669

Closed
wants to merge 1 commit into from

3 participants

@tomchristie

If using a custom user model, with eg USERNAME_FIELD='email',
then it is non-obvious if the correct usage is authenticate(username=..., password=...) or authenticate(email=..., password=...)

Bit of an easy stumbling point, and it won't be obvious to the developer why login is failing, so we should really note the usage here.

This was the best phrasing I could come up with, but happy to take other suggestions.

@tomchristie tomchristie Note `authenticate` usage with custom user model.
If using a custom user model, with eg `USERNAME_FIELD='email'`,
then it is non-obvious if the correct usage is `authenticate(username=..., password=...)` or `authenticate(email=..., password=...)`
Bit of an easy stumbling point, so we should really note the usage here.
341a8a4
@tomchristie

Corresponding trac ticket 19662

@mjtamlyn
Collaborator

:+1: to the change :-1: to the yuk

@aaugustin
Owner

I'm going to close this PR because it doesn't reflect the latest comments on the ticket and the patch is fairly trivial anyway (unless we decide to change the behavior).

@aaugustin aaugustin closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 24, 2013
  1. @tomchristie

    Note `authenticate` usage with custom user model.

    tomchristie authored
    If using a custom user model, with eg `USERNAME_FIELD='email'`,
    then it is non-obvious if the correct usage is `authenticate(username=..., password=...)` or `authenticate(email=..., password=...)`
    Bit of an easy stumbling point, so we should really note the usage here.
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 0 deletions.
  1. +5 −0 docs/topics/auth/default.txt
View
5 docs/topics/auth/default.txt
@@ -136,6 +136,11 @@ Authenticating Users
# the authentication system was unable to verify the username and password
print("The username and password were incorrect.")
+ .. note::
+
+ When calling ``authenticate`` for a custom user model, you should use the ``username``
+ keyword as the first argument, even if ``USERNAME_FIELD`` has been set to some other field.
+
.. _topic-authorization:
Permissions and Authorization
Something went wrong with that request. Please try again.