summaryrefslogtreecommitdiff
path: root/docs/model-api.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-06-07 02:46:08 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-06-07 02:46:08 +0000
commitf3f002b1610ac51044e1e6dff5b7ff8f00b9f4dd (patch)
tree86e7fc9d0efa225a76bff975bbea2e7af856eb3a /docs/model-api.txt
parent448becefdf1e84f143720a01fd1e61869ffe4e5f (diff)
Fixed #1697 and #2095 -- Made 'choices' parameter accept any iterable
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3094 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/model-api.txt')
-rw-r--r--docs/model-api.txt9
1 files changed, 8 insertions, 1 deletions
diff --git a/docs/model-api.txt b/docs/model-api.txt
index c6707a691b..637318c6cc 100644
--- a/docs/model-api.txt
+++ b/docs/model-api.txt
@@ -445,7 +445,8 @@ empty value. If a field has ``blank=False``, the field will be required.
``choices``
~~~~~~~~~~~
-A list of 2-tuples to use as choices for this field.
+An iterable (e.g., a list or tuple) of 2-tuples to use as choices for this
+field.
If this is given, Django's admin will use a select box instead of the
standard text field and will limit choices to the choices given.
@@ -481,6 +482,12 @@ or outside your model class altogether::
class Foo(models.Model):
gender = models.CharField(maxlength=1, choices=GENDER_CHOICES)
+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 ``choices`` to be dynamic, you're probably better off using
+a proper database table with a ``ForeignKey``. ``choices`` is meant for static
+data that doesn't change much, if ever.
+
``core``
~~~~~~~~