mirror of
https://github.com/django/django.git
synced 2025-11-25 21:22:14 +00:00
Fixed #21832 -- Updated prompt, tests, and docs to show that USERNAME_FIELD supports FK after 9bc2d76.
Also added get_input_data() hook in createsuperuser. Thanks Chris Jerdonek and Tim Graham for review.
This commit is contained in:
parent
136a3ffe21
commit
75ff7b8fb8
6 changed files with 63 additions and 31 deletions
|
|
@ -1478,6 +1478,16 @@ it when running interactively.
|
|||
Use the ``--database`` option to specify the database into which the superuser
|
||||
object will be saved.
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
You can subclass the management command and override ``get_input_data()`` if you
|
||||
want to customize data input and validation. Consult the source code for
|
||||
details on the existing implementation and the method's parameters. For example,
|
||||
it could be useful if you have a ``ForeignKey`` in
|
||||
:attr:`~django.contrib.auth.models.CustomUser.REQUIRED_FIELDS` and want to
|
||||
allow creating an instance instead of entering the primary key of an existing
|
||||
instance.
|
||||
|
||||
``django.contrib.gis``
|
||||
----------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ Minor features
|
|||
* The ``max_length`` of :attr:`Permission.name
|
||||
<django.contrib.auth.models.Permission.name>` has been increased from 50 to
|
||||
255 characters. Please run the database migration.
|
||||
* :attr:`~django.contrib.auth.models.CustomUser.REQUIRED_FIELDS` now supports
|
||||
* :attr:`~django.contrib.auth.models.CustomUser.USERNAME_FIELD` and
|
||||
:attr:`~django.contrib.auth.models.CustomUser.REQUIRED_FIELDS` now supports
|
||||
:class:`~django.db.models.ForeignKey`\s.
|
||||
|
||||
:mod:`django.contrib.formtools`
|
||||
|
|
|
|||
|
|
@ -508,6 +508,15 @@ password resets. You must then provide some key implementation details:
|
|||
...
|
||||
USERNAME_FIELD = 'identifier'
|
||||
|
||||
.. versionadded:: 1.8
|
||||
|
||||
:attr:`USERNAME_FIELD` now supports
|
||||
:class:`~django.db.models.ForeignKey`\s. Since there is no way to pass
|
||||
model instances during the :djadmin:`createsuperuser` prompt, expect the
|
||||
user to enter the value of :attr:`~django.db.models.ForeignKey.to_field`
|
||||
value (the :attr:`~django.db.models.Field.primary_key` by default) of an
|
||||
existing instance.
|
||||
|
||||
.. attribute:: REQUIRED_FIELDS
|
||||
|
||||
A list of the field names that will be prompted for when creating a
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue