diff options
| author | antoliny0919 <antoliny0919@gmail.com> | 2024-12-25 11:35:27 +0900 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-01-10 12:57:53 +0100 |
| commit | 97ee8b82c2c99bf352df5359bb24a42ea78585b8 (patch) | |
| tree | cf714ede8d5d8ec504b276bdf7c88114a5324c0f /django | |
| parent | 585160586336f3bcd7b694f53cf10db73c56981c (diff) | |
Fixed #36032 -- Rendered URLField values as links in the admin.
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/admin/utils.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index 0fe0e4e6e6..cc8ca5604d 100644 --- a/django/contrib/admin/utils.py +++ b/django/contrib/admin/utils.py @@ -454,6 +454,8 @@ def display_for_field(value, field, empty_value_display, avoid_link=False): return formats.number_format(value) elif isinstance(field, models.FileField) and value and not avoid_link: return format_html('<a href="{}">{}</a>', value.url, value) + elif isinstance(field, models.URLField) and value and not avoid_link: + return format_html('<a href="{}">{}</a>', value, value) elif isinstance(field, models.JSONField) and value: try: return json.dumps(value, ensure_ascii=False, cls=field.encoder) |
