Author: adrian
Date: 2006-07-17 09:59:41 -0500 (Mon, 17 Jul 2006)
New Revision: 3358
Modified:
django/trunk/docs/model-api.txt
Log:
Documented allow_tags attribute for admin change list methods
Modified: django/trunk/docs/model-api.txt
===================================================================
--- django/trunk/docs/model-api.txt 2006-07-17 14:58:39 UTC (rev 3357)
+++ django/trunk/docs/model-api.txt 2006-07-17 14:59:41 UTC (rev 3358)
@@ -1225,6 +1225,24 @@
return self.birthday.strftime('%Y')[:3] + "0's"
decade_born_in.short_description = 'Birth decade'
+ * If the string given is a method of the model, Django will HTML-escape the
+ output by default. If you'd rather not escape the output of the method,
+ give the method an ``allow_tags`` attribute whose value is ``True``.
+
+ Here's a full example model::
+
+ class Person(models.Model):
+ first_name = models.CharField(maxlength=50)
+ last_name = models.CharField(maxlength=50)
+ color_code = models.CharField(maxlength=6)
+
+ class Admin:
+ list_display = ('first_name', 'last_name', 'colored_name')
+
+ def colored_name(self):
+ return '<span style="color: #%s;">%s %s</span>' %
(self.color_code, self.first_name, self.last_name)
+ colored_name.allow_tags = True
+
``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
-~----------~----~----~----~------~----~------~--~---