from django.contrib import admin

from icekit.utils.admin.mixins import ThumbnailAdminMixin

from . import models


class ImageAdmin(ThumbnailAdminMixin, admin.ModelAdmin):
    list_display = ['description', 'title', 'thumbnail']
    list_display_links = ['description', 'thumbnail']
    filter_horizontal = ['categories', ]
    list_filter = ['categories', 'is_active', ]
    # ThumbnailAdminMixin attributes
    thumbnail_field = 'image'
    thumbnail_options = {
        'size': (150, 150),
    }

    def title(self, image):
        return image.title

    def description(self, image):
        return str(image)

admin.site.register(models.Image, ImageAdmin)

from django.contrib import admin

from icekit.utils.admin.mixins import ThumbnailAdminMixin

from . import models


class ImageAdmin(ThumbnailAdminMixin, admin.ModelAdmin):
    list_display = ['thumbnail', 'alt_text', 'title', ]
    list_display_links = ['alt_text', 'thumbnail']
    filter_horizontal = ['categories', ]
    list_filter = ['categories', 'is_active', ]
    search_fields = ['title', 'alt_text', 'caption', 'admin_notes', ]
    # ThumbnailAdminMixin attributes
    thumbnail_field = 'image'
    thumbnail_options = {
        'size': (150, 150),
    }

admin.site.register(models.Image, ImageAdmin)

Add search options for images, reorder field listing, use field names in list display rather than properties.
Add search options for images, reorder field listing, use field names in list display rather than properties.

  from django.contrib import admin
  
  from icekit.utils.admin.mixins import ThumbnailAdminMixin
  
  from . import models
  
  
  class ImageAdmin(ThumbnailAdminMixin, admin.ModelAdmin):
-     list_display = ['description', 'title', 'thumbnail']
+     list_display = ['thumbnail', 'alt_text', 'title', ]
-     list_display_links = ['description', 'thumbnail']
+     list_display_links = ['alt_text', 'thumbnail']
      filter_horizontal = ['categories', ]
      list_filter = ['categories', 'is_active', ]
+     search_fields = ['title', 'alt_text', 'caption', 'admin_notes', ]
      # ThumbnailAdminMixin attributes
      thumbnail_field = 'image'
      thumbnail_options = {
          'size': (150, 150),
      }
  
-     def title(self, image):
-         return image.title
- 
-     def description(self, image):
-         return str(image)
- 
  admin.site.register(models.Image, ImageAdmin)
  
Add search options for images, reorder field listing, use field names in list display rather than properties.
## Code Before:
from django.contrib import admin

from icekit.utils.admin.mixins import ThumbnailAdminMixin

from . import models


class ImageAdmin(ThumbnailAdminMixin, admin.ModelAdmin):
    list_display = ['description', 'title', 'thumbnail']
    list_display_links = ['description', 'thumbnail']
    filter_horizontal = ['categories', ]
    list_filter = ['categories', 'is_active', ]
    # ThumbnailAdminMixin attributes
    thumbnail_field = 'image'
    thumbnail_options = {
        'size': (150, 150),
    }

    def title(self, image):
        return image.title

    def description(self, image):
        return str(image)

admin.site.register(models.Image, ImageAdmin)

## Instruction:
Add search options for images, reorder field listing, use field names in list display rather than properties.
## Code After:
from django.contrib import admin

from icekit.utils.admin.mixins import ThumbnailAdminMixin

from . import models


class ImageAdmin(ThumbnailAdminMixin, admin.ModelAdmin):
    list_display = ['thumbnail', 'alt_text', 'title', ]
    list_display_links = ['alt_text', 'thumbnail']
    filter_horizontal = ['categories', ]
    list_filter = ['categories', 'is_active', ]
    search_fields = ['title', 'alt_text', 'caption', 'admin_notes', ]
    # ThumbnailAdminMixin attributes
    thumbnail_field = 'image'
    thumbnail_options = {
        'size': (150, 150),
    }

admin.site.register(models.Image, ImageAdmin)
