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, 8 months ago
- Finding related objects for instances in a queryset by akaihola 1 year, 2 months ago
- ExtendibleModelAdminMixin by dokterbob 2 years, 6 months ago
- ParentModel and ChildManager for Model Inheritance by jpwatts 3 years, 8 months ago
- Sort Table Headers by insin 4 years, 10 months ago
Comments
I have modified this code slightly, and add maxlength argument, to make admin layout happy with very long urls:
#