summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAlex Couper <alex.couper@glassesdirect.com>2013-07-20 21:49:33 +0000
committerTim Graham <timograham@gmail.com>2013-07-31 14:12:03 -0400
commit1123f4551158b7fc65d3bd88c375a4517dcd0720 (patch)
treecfded236931c3360205bf35351d81c75a78ef743 /docs
parenta1889397a9f0e6a35189de455098b4c70923e561 (diff)
Fixed #20649 -- Allowed blank field display to be defined in the initial list of choices.
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/fields.txt19
-rw-r--r--docs/releases/1.7.txt5
2 files changed, 19 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``
-------------
diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt
index b75fd89f4c..c47a392dff 100644
--- a/docs/releases/1.7.txt
+++ b/docs/releases/1.7.txt
@@ -105,6 +105,11 @@ Minor features
<django.contrib.auth.forms.AuthenticationForm.confirm_login_allowed>` method
to more easily customize the login policy.
+* :attr:`Field.choices<django.db.models.Field.choices>` now allows you to
+ customize the "empty choice" label by including a tuple with an empty string
+ or ``None`` for the key and the custom label as the value. The default blank
+ option ``"----------"`` will be omitted in this case.
+
Backwards incompatible changes in 1.7
=====================================