1 2 3 4 5 6 | def link(field, desc):
def _link(self):
return '<a href="%(url)s">%(url)s</a>' % {'url': getattr(self, field)}
_link.short_description = desc
_link.allow_tags = True
return _link
|
More like this
- DRY custom ModelAdmin.list_display methods with a decorator by exogen 3 years, 4 months ago
- Finding related objects for instances in a queryset by akaihola 11 months, 1 week ago
- ExtendibleModelAdminMixin by dokterbob 2 years, 2 months ago
- ParentModel and ChildManager for Model Inheritance by jpwatts 3 years, 5 months ago
- FieldLevelPermissionsAdmin by buriy 4 years, 5 months ago
Comments
I have modified this code slightly, and add maxlength argument, to make admin layout happy with very long urls:
#