Author: adrian
Date: 2006-08-23 10:40:41 -0500 (Wed, 23 Aug 2006)
New Revision: 3652
Modified:
django/trunk/docs/model-api.txt
Log:
Added some helpful hints to list_display documentation in docs/model-api.txt
Modified: django/trunk/docs/model-api.txt
===================================================================
--- django/trunk/docs/model-api.txt 2006-08-23 02:42:15 UTC (rev 3651)
+++ django/trunk/docs/model-api.txt 2006-08-23 15:40:41 UTC (rev 3652)
@@ -1222,10 +1222,13 @@
of the related object.
* ``ManyToManyField`` fields aren't supported, because that would entail
- executing a separate SQL statement for each row in the table.
+ executing a separate SQL statement for each row in the table. If you
+ want to do this nonetheless, give your model a custom method, and add
+ that method's name to ``list_display``. (See below for more on custom
+ methods in ``list_display``.)
- * If the field is a ``BooleanField``, Django will display a pretty "on" or
- "off" icon instead of ``True`` or ``False``.
+ * If the field is a ``BooleanField`` or ``NullBooleanField``, Django will
+ display a pretty "on" or "off" icon instead of ``True`` or ``False``.
* If the string given is a method of the model, Django will call it and
display the output. This method should have a ``short_description``
@@ -1262,6 +1265,16 @@
return '<span style="color: #%s;">%s %s</span>' %
(self.color_code, self.first_name, self.last_name)
colored_name.allow_tags = True
+ * The ``__str__()`` method is just as valid in ``list_display`` as any
+ other model method, so it's perfectly OK to do this::
+
+ list_display = ('__str__', 'some_other_field')
+
+ * For any element of ``list_display`` that is not a field on the model, the
+ change list page will not allow ordering by that column. This is because
+ ordering is done at the database level, and Django has no way of knowing
+ how to order the result of a custom method at the SQL level.
+
``list_display_links``
----------------------
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---