diff options
| author | Joseph Kocherhans <joseph@jkocherhans.com> | 2008-04-18 23:53:24 +0000 |
|---|---|---|
| committer | Joseph Kocherhans <joseph@jkocherhans.com> | 2008-04-18 23:53:24 +0000 |
| commit | 0f5ffbf23ea85117b04bee0a5fae721ff18e55c1 (patch) | |
| tree | 6b0abc3899e9c5716fce161ac08308c8083ad670 /docs/newforms.txt | |
| parent | 04932c6f1649672a6d09fa8eff4ef99e6af8aaac (diff) | |
newforms-admin: Merged from trunk up to [7435].
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7436 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/newforms.txt')
| -rw-r--r-- | docs/newforms.txt | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/docs/newforms.txt b/docs/newforms.txt index 4f59400949..41930c0605 100644 --- a/docs/newforms.txt +++ b/docs/newforms.txt @@ -1552,12 +1552,15 @@ additional required argument: ``ModelChoiceField`` ~~~~~~~~~~~~~~~~~~~~ -Allows the selection of a single model object, suitable for representing a -foreign key. The method receives an object as an argument and must return a -string to represent it. +Allows the selection of a single model object, suitable for +representing a foreign key. -The labels for the choice field call the ``__unicode__`` method of the model to -generate string representations. To provide custom labels, subclass ``ModelChoiceField`` and override ``label_for_model``:: +The ``__unicode__`` method of the model will be called to generate +string representations of the objects for use in the field's choices; +to provide customized representations, subclass ``ModelChoiceField`` +and override ``label_from_instance``. This method will receive a model +object, and should return a string suitable for representing it. For +example:: class MyModelChoiceField(ModelChoiceField): def label_from_instance(self, obj): @@ -1566,9 +1569,10 @@ generate string representations. To provide custom labels, subclass ``ModelChoic ``ModelMultipleChoiceField`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Allows the selection of one or more model objects, suitable for representing a -many-to-many relation. As with ``ModelChoiceField``, you can use -``label_from_instance`` to customize the object labels. +Allows the selection of one or more model objects, suitable for +representing a many-to-many relation. As with ``ModelChoiceField``, +you can use ``label_from_instance`` to customize the object +representations. Creating custom fields ---------------------- |
