﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17549	Add link to open URL from URLField	Chris Wilson	nobody	"It's useful for URLField to give you a way to open the URL; otherwise you might as well use a CharField.

{{{

class URLFieldWidgetWithLink(AdminURLFieldWidget):
    def render(self, name, value, attrs=None):
        html = AdminURLFieldWidget.render(self, name, value, attrs=attrs)

        if value is not None:
            final_attrs = dict(href=value, target='_blank')
            html += "" <a %s>(open)</a>"" % attributes_to_str(final_attrs)
        
        from django.utils.safestring import mark_safe
        return mark_safe(html)

class DocumentAdmin(admin.ModelAdmin):
    formfield_overrides = {
        django_fields.URLField: {'widget': URLFieldWidgetWithLink},
    }
}}}"	New feature	closed	contrib.admin	dev	Normal	fixed		tomas.ehrlich@…	Accepted	1	0	0	0	0	1
