Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ModelAdmin(admin.ModelAdmin):
- def view_link(obj):
- return u"<a href='view/%d/'>View</a>" % obj.id
- view_link.short_description = ''
- view_link.allow_tags = True
- list_display = ('id', view_link)
- class Person(models.Model):
- first_name = models.CharField(max_length=50)
- last_name = models.CharField(max_length=50)
- color_code = models.CharField(max_length=6)
- def colored_name(self):
- return '<span style="color: #%s;">%s %s</span>' % (self.color_code, self.first_name, self.last_name)
- colored_name.allow_tags = True
- class PersonAdmin(admin.ModelAdmin):
- list_display = ('first_name', 'last_name', 'colored_name')
- def get_absolute_url(self):
- return '/profiles/%s/' % (self.id)
- def profile_link(self):
- return '<a href="%s">%s</a>' % (self.get_absolute_url(), self.username)
- profile_link.allow_tags = True
- class PersonAdmin(admin.ModelAdmin):
- list_display = ('first_name', 'last_name', 'colored_name', 'profile_link')
Add Comment
Please, Sign In to add comment