Show badge images in Admin interface
This commit is contained in:
parent
0ca75a9baf
commit
8c3358a60b
1 changed files with 5 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
from django.contrib import admin
|
||||
from django.utils.safestring import mark_safe
|
||||
|
||||
from .models import Account, Badge, BadgeGrant
|
||||
|
||||
|
@ -8,7 +9,10 @@ class AccountAdmin(admin.ModelAdmin):
|
|||
admin.site.register(Account, AccountAdmin)
|
||||
|
||||
class BadgeAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'img_url')
|
||||
list_display = ('name', 'icon', 'img_url')
|
||||
def icon(self, obj):
|
||||
return (mark_safe('<img src="%s" title="%s" height="32px" width="32px"/>' % (obj.img_url, obj.name)))
|
||||
icon.short_description = 'Icon'
|
||||
admin.site.register(Badge, BadgeAdmin)
|
||||
|
||||
class GrantAdmin(admin.ModelAdmin):
|
||||
|
|
Loading…
Reference in a new issue