from django.contrib import admin
from django.utils.html import format_html
from .models import Teachers
# Register your models here.


class adminTeacher (admin.ModelAdmin):
    list_display =['image_preview','name', 'designation', 'is_active']
    readonly_fields = ('form_image_preview',)



    def image_preview(self, obj):
        if obj.image:
            return format_html('<img src="{}" style="width: auto; height: 40px; border-radius: 8px;" />', obj.image.url)
        return 'No Image'
    image_preview.short_description = 'Image'


    def form_image_preview(self, obj):
        if obj.image:
            return format_html('<img src="{}" style="width: 100px; height: auto; border-radius: 12px; border: 2px solid #ccc;" />', obj.image.url)
        return "No Image"
    form_image_preview.short_description = 'Current Icon Preview'

admin.site.register(Teachers, adminTeacher)
        