Kaydet (Commit) 96604fdf authored tarafından Jacob Kaplan-Moss's avatar Jacob Kaplan-Moss

Fixed #3455: added documentation of Model.get_FIELD_display(). Thanks, Ubernostrum.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4625 bcc190cf-cafb-0310-a4f2-bffc1f526a37
üst 9f1bf465
......@@ -498,6 +498,13 @@ or outside your model class altogether::
class Foo(models.Model):
gender = models.CharField(maxlength=1, choices=GENDER_CHOICES)
For each field on your model which has ``choices`` set, Django will
add a method to retrieve the human-readable name for the field's
current value; see `get_FOO_display`_ in the database API
documentation.
.. _get_FOO_display: ../db_api/#get-foo-display
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment