Show badge images in Admin interface

This commit is contained in:
Michael Hall 2018-02-09 15:35:40 -05:00
parent 0ca75a9baf
commit 8c3358a60b

View file

@ -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):