summaryrefslogtreecommitdiff
path: root/docs/model-api.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-07-17 14:59:41 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-07-17 14:59:41 +0000
commitc6cbfb3d7c4280ebc058f136c333d7f4db098b69 (patch)
treea818a15a9ca34bc2e337ff95fd5f60c240c80c5a /docs/model-api.txt
parente26f288823458c2d728766250f39c21ab9786b78 (diff)
Documented allow_tags attribute for admin change list methods
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3358 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/model-api.txt')
-rw-r--r--docs/model-api.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/docs/model-api.txt b/docs/model-api.txt
index c4d57bf8c4..c369508c65 100644
--- a/docs/model-api.txt
+++ b/docs/model-api.txt
@@ -1225,6 +1225,24 @@ A few special cases to note about ``list_display``:
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``
----------------------