diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2005-11-11 17:15:24 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2005-11-11 17:15:24 +0000 |
| commit | 632b63ad76efafff2f602de9c5a4464faa37d51b (patch) | |
| tree | 367a7bff0e83a8a262160f7de4a7d265a654c6d2 | |
| parent | cb222e4d4e5f3ebe4ba6773c8e39bc5702f4af57 (diff) | |
Fixed #766 -- Custom methods in admin.list_display can now have an allow_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
| -rw-r--r-- | django/contrib/admin/views/main.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 726ffa5eb2..81c494b03f 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -388,10 +388,16 @@ def change_list(request, app_label, module_name): except meta.FieldDoesNotExist: # For non-field list_display values, the value is a method # name. Execute the method. + func = getattr(result, field_name) try: - result_repr = strip_tags(str(getattr(result, field_name)())) + result_repr = str(func()) except ObjectDoesNotExist: result_repr = EMPTY_CHANGELIST_VALUE + else: + # Strip HTML tags in the resulting text, except if the + # function has an "allow_tags" attribute set to True. + if not getattr(func, 'allow_tags', False): + result_repr = strip_tags(result_repr) else: field_val = getattr(result, f.attname) # Foreign-key fields are special: Use the repr of the |
