
from django.contrib import admin

from blanc_pages.admin import BlancPageAdminMixin

from .models import Category, Event


@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    search_fields = ('title',)
    prepopulated_fields = {
        'slug': ('title',)
    }


@admin.register(Event)
class EventAdmin(BlancPageAdminMixin, admin.ModelAdmin):
    pass
    fieldsets = (
        ('Event', {
            'fields': (
                'title', 'category', 'location', 'image', 'summary', 'start', 'end'
            )
        }),
        ('Advanced options', {
            'fields': ('slug',)
        }),
    )
    date_hierarchy = 'start'
    list_display = ('title', 'start', 'end', 'category',)
    list_filter = ('published', 'start', 'category__title',)
    prepopulated_fields = {
        'slug': ('title',)
    }


from django.contrib import admin

from blanc_pages.admin import BlancPageAdminMixin

from .models import Category, Event


@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    search_fields = ('title',)
    prepopulated_fields = {
        'slug': ('title',)
    }


@admin.register(Event)
class EventAdmin(BlancPageAdminMixin, admin.ModelAdmin):
    fieldsets = (
        ('Event', {
            'fields': (
                'title', 'category', 'location', 'image', 'summary', 'start', 'end'
            )
        }),
        ('Advanced options', {
            'fields': ('slug',)
        }),
    )
    date_hierarchy = 'start'
    list_display = ('title', 'start', 'end', 'category',)
    list_filter = ('published', 'start', 'category',)
    prepopulated_fields = {
        'slug': ('title',)
    }

Use category, not category title for list_filter
Use category, not category title for list_filter

  
  from django.contrib import admin
  
  from blanc_pages.admin import BlancPageAdminMixin
  
  from .models import Category, Event
  
  
  @admin.register(Category)
  class CategoryAdmin(admin.ModelAdmin):
      search_fields = ('title',)
      prepopulated_fields = {
          'slug': ('title',)
      }
  
  
  @admin.register(Event)
  class EventAdmin(BlancPageAdminMixin, admin.ModelAdmin):
-     pass
      fieldsets = (
          ('Event', {
              'fields': (
                  'title', 'category', 'location', 'image', 'summary', 'start', 'end'
              )
          }),
          ('Advanced options', {
              'fields': ('slug',)
          }),
      )
      date_hierarchy = 'start'
      list_display = ('title', 'start', 'end', 'category',)
-     list_filter = ('published', 'start', 'category__title',)
+     list_filter = ('published', 'start', 'category',)
      prepopulated_fields = {
          'slug': ('title',)
      }
  
Use category, not category title for list_filter
## Code Before:

from django.contrib import admin

from blanc_pages.admin import BlancPageAdminMixin

from .models import Category, Event


@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    search_fields = ('title',)
    prepopulated_fields = {
        'slug': ('title',)
    }


@admin.register(Event)
class EventAdmin(BlancPageAdminMixin, admin.ModelAdmin):
    pass
    fieldsets = (
        ('Event', {
            'fields': (
                'title', 'category', 'location', 'image', 'summary', 'start', 'end'
            )
        }),
        ('Advanced options', {
            'fields': ('slug',)
        }),
    )
    date_hierarchy = 'start'
    list_display = ('title', 'start', 'end', 'category',)
    list_filter = ('published', 'start', 'category__title',)
    prepopulated_fields = {
        'slug': ('title',)
    }

## Instruction:
Use category, not category title for list_filter
## Code After:

from django.contrib import admin

from blanc_pages.admin import BlancPageAdminMixin

from .models import Category, Event


@admin.register(Category)
class CategoryAdmin(admin.ModelAdmin):
    search_fields = ('title',)
    prepopulated_fields = {
        'slug': ('title',)
    }


@admin.register(Event)
class EventAdmin(BlancPageAdminMixin, admin.ModelAdmin):
    fieldsets = (
        ('Event', {
            'fields': (
                'title', 'category', 'location', 'image', 'summary', 'start', 'end'
            )
        }),
        ('Advanced options', {
            'fields': ('slug',)
        }),
    )
    date_hierarchy = 'start'
    list_display = ('title', 'start', 'end', 'category',)
    list_filter = ('published', 'start', 'category',)
    prepopulated_fields = {
        'slug': ('title',)
    }
