summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorCaio Ariede <caio.ariede@gmail.com>2019-05-29 09:14:32 -0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-06-04 14:57:08 +0200
commitd6d65c1e87d0da52e43d6359290a7b3f77367576 (patch)
treee7127444ecdf9aa3b091da493a1092775a982dfa /docs/ref
parented3dc5119bd460ee28d6593283199d4b54f4c072 (diff)
[2.2.x] Fixed #30505 -- Doc'd how changes in the order of Field.choices affect migrations.
Backport of 5248abe9b0425c1fc989c60a55860cdb4d135bcf from master
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/models/fields.txt15
1 files changed, 9 insertions, 6 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index a5afcec748..1090d4f66a 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -80,7 +80,7 @@ If a field has ``blank=False``, the field will be required.
.. attribute:: Field.choices
-An :term:`iterable` consisting itself of iterables of exactly two items (e.g.
+A :term:`sequence` consisting itself of iterables of exactly two items (e.g.
``[(A, B), (A, B) ...]``) to use as choices for this field. If choices are
given, they're enforced by :ref:`model validation <validating-objects>` and the
default form widget will be a select box with these choices instead of the
@@ -155,11 +155,14 @@ method to retrieve the human-readable name for the field's current value. See
:meth:`~django.db.models.Model.get_FOO_display` in the database API
documentation.
-Note that choices can be any iterable object -- not necessarily a list or tuple.
-This lets you construct choices dynamically. But if you find yourself hacking
-:attr:`~Field.choices` to be dynamic, you're probably better off using a proper
-database table with a :class:`ForeignKey`. :attr:`~Field.choices` is meant for
-static data that doesn't change much, if ever.
+Note that choices can be any sequence object -- not necessarily a list or
+tuple. This lets you construct choices dynamically. But if you find yourself
+hacking :attr:`~Field.choices` to be dynamic, you're probably better off using
+a proper database table with a :class:`ForeignKey`. :attr:`~Field.choices` is
+meant for static data that doesn't change much, if ever.
+
+.. note::
+ A new migration is created each time the order of ``choices`` changes.
Unless :attr:`blank=False<Field.blank>` is set on the field along with a
:attr:`~Field.default` then a label containing ``"---------"`` will be rendered