Kaydet (Commit) 93a08194 authored tarafından Tim Graham's avatar Tim Graham

Normalized casing of "custom user model".

üst d02a03d5
...@@ -15,7 +15,7 @@ version >= 2.2 and mod_wsgi >= 2.0. For example, you could: ...@@ -15,7 +15,7 @@ version >= 2.2 and mod_wsgi >= 2.0. For example, you could:
* Allow certain users to connect to a WebDAV share created with mod_dav_. * Allow certain users to connect to a WebDAV share created with mod_dav_.
.. note:: .. note::
If you have installed a :ref:`custom User model <auth-custom-user>` and If you have installed a :ref:`custom user model <auth-custom-user>` and
want to use this default auth handler, it must support an ``is_active`` want to use this default auth handler, it must support an ``is_active``
attribute. If you want to use group based authorization, your custom user attribute. If you want to use group based authorization, your custom user
must have a relation named 'groups', referring to a related object that has must have a relation named 'groups', referring to a related object that has
......
...@@ -183,9 +183,9 @@ Methods ...@@ -183,9 +183,9 @@ Methods
.. method:: get_username() .. method:: get_username()
Returns the username for the user. Since the User model can be swapped Returns the username for the user. Since the ``User`` model can be
out, you should use this method instead of referencing the username swapped out, you should use this method instead of referencing the
attribute directly. username attribute directly.
.. method:: get_full_name() .. method:: get_full_name()
...@@ -305,7 +305,7 @@ Manager methods ...@@ -305,7 +305,7 @@ Manager methods
The ``extra_fields`` keyword arguments are passed through to the The ``extra_fields`` keyword arguments are passed through to the
:class:`~django.contrib.auth.models.User`’s ``__init__`` method to :class:`~django.contrib.auth.models.User`’s ``__init__`` method to
allow setting arbitrary fields on a :ref:`custom User model allow setting arbitrary fields on a :ref:`custom user model
<auth-custom-user>`. <auth-custom-user>`.
See :ref:`Creating users <topics-auth-creating-users>` for example usage. See :ref:`Creating users <topics-auth-creating-users>` for example usage.
...@@ -615,16 +615,14 @@ The following backends are available in :mod:`django.contrib.auth.backends`: ...@@ -615,16 +615,14 @@ The following backends are available in :mod:`django.contrib.auth.backends`:
.. attribute:: RemoteUserBackend.create_unknown_user .. attribute:: RemoteUserBackend.create_unknown_user
``True`` or ``False``. Determines whether or not a ``True`` or ``False``. Determines whether or not a user object is created
:class:`~django.contrib.auth.models.User` object is created if not already if not already in the database Defaults to ``True``.
in the database. Defaults to ``True``.
.. method:: RemoteUserBackend.authenticate(request, remote_user) .. method:: RemoteUserBackend.authenticate(request, remote_user)
The username passed as ``remote_user`` is considered trusted. This method The username passed as ``remote_user`` is considered trusted. This method
simply returns the ``User`` object with the given username, creating a new simply returns the user object with the given username, creating a new
``User`` object if :attr:`~RemoteUserBackend.create_unknown_user` is user object if :attr:`~RemoteUserBackend.create_unknown_user` is ``True``.
``True``.
Returns ``None`` if :attr:`~RemoteUserBackend.create_unknown_user` is Returns ``None`` if :attr:`~RemoteUserBackend.create_unknown_user` is
``False`` and a ``User`` object with the given username is not found in the ``False`` and a ``User`` object with the given username is not found in the
...@@ -637,9 +635,8 @@ The following backends are available in :mod:`django.contrib.auth.backends`: ...@@ -637,9 +635,8 @@ The following backends are available in :mod:`django.contrib.auth.backends`:
.. method:: RemoteUserBackend.clean_username(username) .. method:: RemoteUserBackend.clean_username(username)
Performs any cleaning on the ``username`` (e.g. stripping LDAP DN Performs any cleaning on the ``username`` (e.g. stripping LDAP DN
information) prior to using it to get or create a information) prior to using it to get or create a user object. Returns the
:class:`~django.contrib.auth.models.User` object. Returns the cleaned cleaned username.
username.
.. method:: RemoteUserBackend.configure_user(user) .. method:: RemoteUserBackend.configure_user(user)
......
...@@ -133,7 +133,7 @@ you may need to make some changes to the way you reference User instances. You ...@@ -133,7 +133,7 @@ you may need to make some changes to the way you reference User instances. You
should also document any specific features of the User model that your should also document any specific features of the User model that your
application relies upon. application relies upon.
See the :ref:`documentation on custom User models <auth-custom-user>` for See the :ref:`documentation on custom user models <auth-custom-user>` for
more details. more details.
Support for saving a subset of model's fields Support for saving a subset of model's fields
...@@ -560,7 +560,7 @@ Prior to Django 1.5, if you attempted to log into the admin interface and ...@@ -560,7 +560,7 @@ Prior to Django 1.5, if you attempted to log into the admin interface and
mistakenly used your email address instead of your username, the admin mistakenly used your email address instead of your username, the admin
interface would provide a warning advising that your email address was interface would provide a warning advising that your email address was
not your username. In Django 1.5, the introduction of not your username. In Django 1.5, the introduction of
:ref:`custom User models <auth-custom-user>` has required the removal of this :ref:`custom user models <auth-custom-user>` has required the removal of this
warning. This doesn't change the login behavior of the admin site; it only warning. This doesn't change the login behavior of the admin site; it only
affects the warning message that is displayed under one particular mode of affects the warning message that is displayed under one particular mode of
login failure. login failure.
...@@ -741,7 +741,7 @@ framework. ...@@ -741,7 +741,7 @@ framework.
``AUTH_PROFILE_MODULE`` ``AUTH_PROFILE_MODULE``
----------------------- -----------------------
With the introduction of :ref:`custom User models <auth-custom-user>`, there is With the introduction of :ref:`custom user models <auth-custom-user>`, there is
no longer any need for a built-in mechanism to store user profile data. no longer any need for a built-in mechanism to store user profile data.
You can still define user profiles models that have a one-to-one relation with You can still define user profiles models that have a one-to-one relation with
......
...@@ -448,7 +448,7 @@ removed and the standalone GeoDjango tests execution setup it implemented isn't ...@@ -448,7 +448,7 @@ removed and the standalone GeoDjango tests execution setup it implemented isn't
supported anymore. To run the GeoDjango tests simply use the new supported anymore. To run the GeoDjango tests simply use the new
``DiscoverRunner`` and specify the ``django.contrib.gis`` app. ``DiscoverRunner`` and specify the ``django.contrib.gis`` app.
Custom User models in tests Custom user models in tests
--------------------------- ---------------------------
The introduction of the new test runner has also slightly changed the way that The introduction of the new test runner has also slightly changed the way that
......
...@@ -86,7 +86,7 @@ function is used when creating a user. ...@@ -86,7 +86,7 @@ function is used when creating a user.
To change a user's password, you have several options: To change a user's password, you have several options:
:djadmin:`manage.py changepassword *username* <changepassword>` offers a method :djadmin:`manage.py changepassword *username* <changepassword>` offers a method
of changing a User's password from the command line. It prompts you to of changing a user's password from the command line. It prompts you to
change the password of a given user which you must enter twice. If change the password of a given user which you must enter twice. If
they both match, the new password will be changed immediately. If you they both match, the new password will be changed immediately. If you
do not supply a user, the command will attempt to change the password do not supply a user, the command will attempt to change the password
...@@ -267,12 +267,12 @@ Permission caching ...@@ -267,12 +267,12 @@ Permission caching
------------------ ------------------
The :class:`~django.contrib.auth.backends.ModelBackend` caches permissions on The :class:`~django.contrib.auth.backends.ModelBackend` caches permissions on
the ``User`` object after the first time they need to be fetched for a the user object after the first time they need to be fetched for a permissions
permissions check. This is typically fine for the request-response cycle since check. This is typically fine for the request-response cycle since permissions
permissions are not typically checked immediately after they are added (in the aren't typically checked immediately after they are added (in the admin, for
admin, for example). If you are adding permissions and checking them immediately example). If you are adding permissions and checking them immediately
afterward, in a test or view for example, the easiest solution is to re-fetch afterward, in a test or view for example, the easiest solution is to re-fetch
the ``User`` from the database. For example:: the user from the database. For example::
from django.contrib.auth.models import Permission, User from django.contrib.auth.models import Permission, User
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
...@@ -380,7 +380,7 @@ is selected as follows: ...@@ -380,7 +380,7 @@ is selected as follows:
pairing :func:`~django.contrib.auth.authenticate()` and pairing :func:`~django.contrib.auth.authenticate()` and
:func:`~django.contrib.auth.login()`: :func:`~django.contrib.auth.login()`:
:func:`~django.contrib.auth.authenticate()` :func:`~django.contrib.auth.authenticate()`
sets the ``user.backend`` attribute on the ``User`` object it returns. sets the ``user.backend`` attribute on the user object it returns.
#. Use the ``backend`` in :setting:`AUTHENTICATION_BACKENDS`, if there is only #. Use the ``backend`` in :setting:`AUTHENTICATION_BACKENDS`, if there is only
one. one.
#. Otherwise, raise an exception. #. Otherwise, raise an exception.
...@@ -1602,7 +1602,7 @@ provides several built-in forms located in :mod:`django.contrib.auth.forms`: ...@@ -1602,7 +1602,7 @@ provides several built-in forms located in :mod:`django.contrib.auth.forms`:
.. note:: .. note::
The built-in authentication forms make certain assumptions about the user The built-in authentication forms make certain assumptions about the user
model that they are working with. If you're using a :ref:`custom User model model that they are working with. If you're using a :ref:`custom user model
<auth-custom-user>`, it may be necessary to define your own forms for the <auth-custom-user>`, it may be necessary to define your own forms for the
authentication system. For more information, refer to the documentation authentication system. For more information, refer to the documentation
about :ref:`using the built-in authentication forms with custom user models about :ref:`using the built-in authentication forms with custom user models
......
...@@ -6,7 +6,7 @@ from django.db import models ...@@ -6,7 +6,7 @@ from django.db import models
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import python_2_unicode_compatible
# The custom User uses email as the unique identifier, and requires # The custom user uses email as the unique identifier, and requires
# that every user provide a date of birth. This lets us test # that every user provide a date of birth. This lets us test
# changes in username datatype, and non-text required fields. # changes in username datatype, and non-text required fields.
class CustomUserManager(BaseUserManager): class CustomUserManager(BaseUserManager):
......
...@@ -263,7 +263,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase): ...@@ -263,7 +263,7 @@ class CreatesuperuserManagementCommandTestCase(TestCase):
@override_settings(AUTH_USER_MODEL='auth_tests.CustomUser') @override_settings(AUTH_USER_MODEL='auth_tests.CustomUser')
def test_swappable_user(self): def test_swappable_user(self):
"A superuser can be created when a custom User model is in use" "A superuser can be created when a custom user model is in use"
# We can use the management command to create a superuser # We can use the management command to create a superuser
# We skip validation because the temporary substitution of the # We skip validation because the temporary substitution of the
# swappable User model messes with validation. # swappable User model messes with validation.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment