diff options
| author | Alex Couper <alex.couper@glassesdirect.com> | 2013-07-20 21:49:33 +0000 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-07-31 14:12:03 -0400 |
| commit | 1123f4551158b7fc65d3bd88c375a4517dcd0720 (patch) | |
| tree | cfded236931c3360205bf35351d81c75a78ef743 /docs/ref | |
| parent | a1889397a9f0e6a35189de455098b4c70923e561 (diff) | |
Fixed #20649 -- Allowed blank field display to be defined in the initial list of choices.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/models/fields.txt | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 869996643f..736a836924 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -152,11 +152,20 @@ 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. -Finally, 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 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. + +.. versionadded:: 1.7 + +Unless :attr:`blank=False<Field.blank>` is set on the field along with a +:attr:`~Field.default` then a label containing ``"---------"`` will be rendered +with the select box. To override this behavior, add a tuple to ``choices`` +containing ``None``; e.g. ``(None, 'Your String For Display')``. +Alternatively, you can use an empty string instead of ``None`` where this makes +sense - such as on a :class:`~django.db.models.CharField`. ``db_column`` ------------- |
