From 1ea87c8c7974acb5fa795362253c61b38f3cb137 Mon Sep 17 00:00:00 2001 From: Alasdair Nicol Date: Fri, 5 Jun 2015 14:33:04 +0100 Subject: Fixed #24910 -- Added createsuperuser support for non-unique USERNAME_FIELDs Clarified docs to say that a non-unique USERNAME_FIELD is permissable as long as the custom auth backend can support it. --- docs/topics/auth/customizing.txt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'docs') diff --git a/docs/topics/auth/customizing.txt b/docs/topics/auth/customizing.txt index 6d06ef6e25..7745574d5d 100644 --- a/docs/topics/auth/customizing.txt +++ b/docs/topics/auth/customizing.txt @@ -477,9 +477,11 @@ Specifying a custom User model Django expects your custom User model to meet some minimum requirements. -#. Your model must have a single unique field that can be used for - identification purposes. This can be a username, an email address, - or any other unique attribute. +#. If you use the default authentication backend, then your model must have a + single unique field that can be used for identification purposes. This can + be a username, an email address, or any other unique attribute. A non-unique + username field is allowed if you use a custom authentication backend that + can support it. #. Your model must provide a way to address the user in a "short" and "long" form. The most common interpretation of this would be to use @@ -506,10 +508,11 @@ password resets. You must then provide some key implementation details: .. attribute:: USERNAME_FIELD A string describing the name of the field on the User model that is - used as the unique identifier. This will usually be a username of - some kind, but it can also be an email address, or any other unique - identifier. The field *must* be unique (i.e., have ``unique=True`` - set in its definition). + used as the unique identifier. This will usually be a username of some + kind, but it can also be an email address, or any other unique + identifier. The field *must* be unique (i.e., have ``unique=True`` set + in its definition), unless you use a custom authentication backend that + can support non-unique usernames. In the following example, the field ``identifier`` is used as the identifying field:: -- cgit v1.3