from django.contrib import admin
from adminsortable2.admin import SortableAdminMixin

from .models import SliderItem

#@admin.register(SliderItem)
class SliderItemAdmin(SortableAdminMixin, admin.ModelAdmin):
    list_display = ['title', 'image_thumbnail']
    search_fields = ['title']
    list_filter = ['title']

    def image_thumbnail(self, obj):
        if obj.image:
            return '<img src="%s" width="50" />' % obj.image.url
        return 'No Image'
    image_thumbnail.allow_tags = True
    image_thumbnail.short_description = 'Thumbnail'

admin.site.register(SliderItem, SliderItemAdmin)
