from django.contrib import admin
from django.utils import timezone
from django.conf import settings
from django.contrib.sites.models import Site


class PublishableAdmin(admin.ModelAdmin):
    """
    Overrides standard admin.ModelAdmin save_model method
    It sets user (author) based on data from requet.
    """
    list_display = ['title', 'channel_name', 'date_available', 'published']
    list_filter = ['date_available', 'published', 'channel_name']
    search_fields = ['title', 'slug', 'headline', 'channel_name']
    exclude = ('user',)

    def save_model(self, request, obj, form, change):
        if getattr(obj, 'pk', None) is None:
            obj.user = request.user
            obj.date_insert = timezone.now()
            obj.site = Site.objects.get(pk=settings.SITE_ID)
        obj.date_update = timezone.now()
        obj.save()

from django.contrib import admin
from django.utils import timezone
from django.conf import settings
from django.contrib.sites.models import Site


class PublishableAdmin(admin.ModelAdmin):
    """
    Overrides standard admin.ModelAdmin save_model method
    It sets user (author) based on data from requet.
    """
    list_display = ['title', 'channel_name', 'date_available', 'published']
    list_filter = ['date_available', 'published', 'channel_name',
                   'child_class']
    search_fields = ['title', 'slug', 'headline', 'channel_name']
    exclude = ('user',)

    def save_model(self, request, obj, form, change):
        if getattr(obj, 'pk', None) is None:
            obj.user = request.user
            obj.date_insert = timezone.now()
            obj.site = Site.objects.get(pk=settings.SITE_ID)
        obj.date_update = timezone.now()
        obj.save()

Add child_class on list filter PublishableAdmin
Add child_class on list filter PublishableAdmin

  from django.contrib import admin
  from django.utils import timezone
  from django.conf import settings
  from django.contrib.sites.models import Site
  
  
  class PublishableAdmin(admin.ModelAdmin):
      """
      Overrides standard admin.ModelAdmin save_model method
      It sets user (author) based on data from requet.
      """
      list_display = ['title', 'channel_name', 'date_available', 'published']
-     list_filter = ['date_available', 'published', 'channel_name']
+     list_filter = ['date_available', 'published', 'channel_name',
+                    'child_class']
      search_fields = ['title', 'slug', 'headline', 'channel_name']
      exclude = ('user',)
  
      def save_model(self, request, obj, form, change):
          if getattr(obj, 'pk', None) is None:
              obj.user = request.user
              obj.date_insert = timezone.now()
              obj.site = Site.objects.get(pk=settings.SITE_ID)
          obj.date_update = timezone.now()
          obj.save()
  
Add child_class on list filter PublishableAdmin
## Code Before:
from django.contrib import admin
from django.utils import timezone
from django.conf import settings
from django.contrib.sites.models import Site


class PublishableAdmin(admin.ModelAdmin):
    """
    Overrides standard admin.ModelAdmin save_model method
    It sets user (author) based on data from requet.
    """
    list_display = ['title', 'channel_name', 'date_available', 'published']
    list_filter = ['date_available', 'published', 'channel_name']
    search_fields = ['title', 'slug', 'headline', 'channel_name']
    exclude = ('user',)

    def save_model(self, request, obj, form, change):
        if getattr(obj, 'pk', None) is None:
            obj.user = request.user
            obj.date_insert = timezone.now()
            obj.site = Site.objects.get(pk=settings.SITE_ID)
        obj.date_update = timezone.now()
        obj.save()

## Instruction:
Add child_class on list filter PublishableAdmin
## Code After:
from django.contrib import admin
from django.utils import timezone
from django.conf import settings
from django.contrib.sites.models import Site


class PublishableAdmin(admin.ModelAdmin):
    """
    Overrides standard admin.ModelAdmin save_model method
    It sets user (author) based on data from requet.
    """
    list_display = ['title', 'channel_name', 'date_available', 'published']
    list_filter = ['date_available', 'published', 'channel_name',
                   'child_class']
    search_fields = ['title', 'slug', 'headline', 'channel_name']
    exclude = ('user',)

    def save_model(self, request, obj, form, change):
        if getattr(obj, 'pk', None) is None:
            obj.user = request.user
            obj.date_insert = timezone.now()
            obj.site = Site.objects.get(pk=settings.SITE_ID)
        obj.date_update = timezone.now()
        obj.save()
