From 4fa61e0e4f35f407f7e62a32ee7729a458ec545d Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 4 Mar 2015 10:26:04 -0500 Subject: [PATCH] [1.8.x] Used format_html() in contrib.admin.utils for consistency. Backport of fe42bfaaff93e6b4af34ab48892e20c9cdee0c1a from master --- django/contrib/admin/utils.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index 65983cb0e6..619e9ad796 100644 --- a/django/contrib/admin/utils.py +++ b/django/contrib/admin/utils.py @@ -13,8 +13,7 @@ from django.db.models.deletion import Collector from django.forms.forms import pretty_name from django.utils import formats, six, timezone from django.utils.encoding import force_str, force_text, smart_text -from django.utils.html import conditional_escape, format_html -from django.utils.safestring import mark_safe +from django.utils.html import format_html from django.utils.text import capfirst from django.utils.translation import ungettext @@ -389,10 +388,7 @@ def display_for_field(value, field): elif isinstance(field, models.FloatField): return formats.number_format(value) elif isinstance(field, models.FileField) and value: - return mark_safe('%s' % ( - conditional_escape(value.url), - conditional_escape(value), - )) + return format_html('{}', value.url, value) else: return smart_text(value)