diff --git a/django/contrib/admin/static/admin/css/widgets.css b/django/contrib/admin/static/admin/css/widgets.css
index 0a7012c..3b19353 100644
a
|
b
|
table p.datetime {
|
225 | 225 | padding-left: 0; |
226 | 226 | } |
227 | 227 | |
| 228 | /* URL */ |
| 229 | |
| 230 | p.url { |
| 231 | line-height: 20px; |
| 232 | margin: 0; |
| 233 | padding: 0; |
| 234 | color: #666; |
| 235 | font-size: 11px; |
| 236 | font-weight: bold; |
| 237 | } |
| 238 | |
| 239 | .url a { |
| 240 | font-weight: normal; |
| 241 | } |
| 242 | |
228 | 243 | /* FILE UPLOADS */ |
229 | 244 | |
230 | 245 | p.file-upload { |
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index 1e0bc2d..bd5f3b0 100644
a
|
b
|
class AdminURLFieldWidget(forms.TextInput):
|
306 | 306 | final_attrs.update(attrs) |
307 | 307 | super(AdminURLFieldWidget, self).__init__(attrs=final_attrs) |
308 | 308 | |
| 309 | def render(self, name, value, attrs=None): |
| 310 | html = super(AdminURLFieldWidget, self).render(name, value, attrs) |
| 311 | if value: |
| 312 | value = force_text(self._format_value(value)) |
| 313 | final_attrs = { |
| 314 | 'href': value, |
| 315 | 'target': '_blank' |
| 316 | } |
| 317 | html = format_html( |
| 318 | '<p class="url">{0} <a {1}>{2}</a><br />{3} {4}</p>', |
| 319 | _('Currently:'), flatatt(final_attrs), value, |
| 320 | _('Change:'), html |
| 321 | ) |
| 322 | return html |
| 323 | |
| 324 | |
309 | 325 | class AdminIntegerFieldWidget(forms.TextInput): |
310 | 326 | class_name = 'vIntegerField' |
311 | 327 | |
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 02d8453..3bca17d 100644
a
|
b
|
Like all :class:`CharField` subclasses, :class:`URLField` takes the optional
|
922 | 922 | :attr:`~CharField.max_length`argument. If you don't specify |
923 | 923 | :attr:`~CharField.max_length`, a default of 200 is used. |
924 | 924 | |
| 925 | .. versionadded:: 1.5 |
| 926 | |
| 927 | The current value of the field will be displayed as a clickable link above the |
| 928 | input widget. |
| 929 | |
925 | 930 | |
926 | 931 | Relationship fields |
927 | 932 | =================== |
diff --git a/tests/regressiontests/admin_widgets/tests.py b/tests/regressiontests/admin_widgets/tests.py
index 4b11543..bbcb2da 100644
a
|
b
|
class AdminSplitDateTimeWidgetTest(DjangoTestCase):
|
266 | 266 | ) |
267 | 267 | |
268 | 268 | |
| 269 | class AdminURLWidgetTest(DjangoTestCase): |
| 270 | def test_render(self): |
| 271 | w = widgets.AdminURLFieldWidget() |
| 272 | self.assertHTMLEqual( |
| 273 | conditional_escape(w.render('test', '')), |
| 274 | '<input class="vURLField" name="test" type="text" />' |
| 275 | ) |
| 276 | self.assertHTMLEqual( |
| 277 | conditional_escape(w.render('test', 'http://example.com')), |
| 278 | '<p class="url">Currently:<a href="http://example.com" target="_blank">http://example.com</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example.com" /></p>' |
| 279 | ) |
| 280 | |
| 281 | def test_render_idn(self): |
| 282 | w = widgets.AdminURLFieldWidget() |
| 283 | self.assertHTMLEqual( |
| 284 | conditional_escape(w.render('test', 'http://example-äüö.com')), |
| 285 | '<p class="url">Currently:<a href="http://example-äüö.com" target="_blank">http://example-äüö.com</a><br />Change:<input class="vURLField" name="test" type="text" value="http://example-äüö.com" /></p>' |
| 286 | ) |
| 287 | |
| 288 | |
269 | 289 | class AdminFileWidgetTest(DjangoTestCase): |
270 | 290 | def test_render(self): |
271 | 291 | band = models.Band.objects.create(name='Linkin Park') |