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
- general-purpose django XMLRC dispatcher by teepark 4 years, 3 months ago
- DRY custom ModelAdmin.list_display methods with a decorator by exogen 4 years, 8 months ago
- ParentModel and ChildManager for Model Inheritance by jpwatts 4 years, 8 months ago
- Multiple querysets by t_rybik 3 years, 2 months ago
- Online boolean switch in the admin list by sasha 5 years, 8 months ago
Comments
I have modified this code slightly, and add maxlength argument, to make admin layout happy with very long urls:
#