mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #17549 -- Added a clickable link for URLFields in admin change list.
This commit is contained in:
committed by
Florian Apolloner
parent
39f5bc7fc3
commit
ac2052ebc8
@@ -225,6 +225,21 @@ table p.datetime {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
/* URL */
|
||||
|
||||
p.url {
|
||||
line-height: 20px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #666;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.url a {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
/* FILE UPLOADS */
|
||||
|
||||
p.file-upload {
|
||||
|
||||
@@ -10,7 +10,7 @@ from django.contrib.admin.templatetags.admin_static import static
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.forms.widgets import RadioFieldRenderer
|
||||
from django.forms.util import flatatt
|
||||
from django.utils.html import escape, format_html, format_html_join
|
||||
from django.utils.html import escape, format_html, format_html_join, smart_urlquote
|
||||
from django.utils.text import Truncator
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.utils.safestring import mark_safe
|
||||
@@ -306,6 +306,19 @@ class AdminURLFieldWidget(forms.TextInput):
|
||||
final_attrs.update(attrs)
|
||||
super(AdminURLFieldWidget, self).__init__(attrs=final_attrs)
|
||||
|
||||
def render(self, name, value, attrs=None):
|
||||
html = super(AdminURLFieldWidget, self).render(name, value, attrs)
|
||||
if value:
|
||||
value = force_text(self._format_value(value))
|
||||
final_attrs = {'href': mark_safe(smart_urlquote(value))}
|
||||
html = format_html(
|
||||
'<p class="url">{0} <a {1}>{2}</a><br />{3} {4}</p>',
|
||||
_('Currently:'), flatatt(final_attrs), value,
|
||||
_('Change:'), html
|
||||
)
|
||||
return html
|
||||
|
||||
|
||||
class AdminIntegerFieldWidget(forms.TextInput):
|
||||
class_name = 'vIntegerField'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user