Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #766 -- Custom methods in admin.list_display can now have an al…

…low_tags attribute, which doesn't strip tags in the methods' output. Thanks, plisk

git-svn-id: http://code.djangoproject.com/svn/django/trunk@1174 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 632b63ad76efafff2f602de9c5a4464faa37d51b 1 parent cb222e4
Adrian Holovaty authored November 11, 2005

Showing 1 changed file with 7 additions and 1 deletion. Show diff stats Hide diff stats

  1. 8  django/contrib/admin/views/main.py
8  django/contrib/admin/views/main.py
@@ -388,10 +388,16 @@ def change_list(request, app_label, module_name):
388 388
                 except meta.FieldDoesNotExist:
389 389
                     # For non-field list_display values, the value is a method
390 390
                     # name. Execute the method.
  391
+                    func = getattr(result, field_name)
391 392
                     try:
392  
-                        result_repr = strip_tags(str(getattr(result, field_name)()))
  393
+                        result_repr = str(func())
393 394
                     except ObjectDoesNotExist:
394 395
                         result_repr = EMPTY_CHANGELIST_VALUE
  396
+                    else:
  397
+                        # Strip HTML tags in the resulting text, except if the
  398
+                        # function has an "allow_tags" attribute set to True.
  399
+                        if not getattr(func, 'allow_tags', False):
  400
+                            result_repr = strip_tags(result_repr)
395 401
                 else:
396 402
                     field_val = getattr(result, f.attname)
397 403
                     # Foreign-key fields are special: Use the repr of the

0 notes on commit 632b63a

Please sign in to comment.
Something went wrong with that request. Please try again.