from django.contrib import admin
from ledger.models import Account, Entry


class EntryAdmin(admin.ModelAdmin):
    list_display = ['date', 'amount', 'details', 'debit_account', 'credit_account']
    list_filter = ['date']


admin.site.register(Entry, EntryAdmin)
admin.site.register(Account)

from django.contrib import admin
from ledger.models import Account, Entry


class EntryAdmin(admin.ModelAdmin):
    list_display = ['date', 'amount', 'details', 'debit_account', 'credit_account']
    list_filter = ['date', 'debit_account', 'credit_account']
    search_fields = ['details', 'debit_account__name', 'credit_account__name']
    ordering = ['-date']


admin.site.register(Entry, EntryAdmin)
admin.site.register(Account)

Add a little more functionality to EntryAdmin
Add a little more functionality to EntryAdmin

  from django.contrib import admin
  from ledger.models import Account, Entry
  
  
  class EntryAdmin(admin.ModelAdmin):
      list_display = ['date', 'amount', 'details', 'debit_account', 'credit_account']
-     list_filter = ['date']
+     list_filter = ['date', 'debit_account', 'credit_account']
+     search_fields = ['details', 'debit_account__name', 'credit_account__name']
+     ordering = ['-date']
  
  
  admin.site.register(Entry, EntryAdmin)
  admin.site.register(Account)
  
Add a little more functionality to EntryAdmin
## Code Before:
from django.contrib import admin
from ledger.models import Account, Entry


class EntryAdmin(admin.ModelAdmin):
    list_display = ['date', 'amount', 'details', 'debit_account', 'credit_account']
    list_filter = ['date']


admin.site.register(Entry, EntryAdmin)
admin.site.register(Account)

## Instruction:
Add a little more functionality to EntryAdmin
## Code After:
from django.contrib import admin
from ledger.models import Account, Entry


class EntryAdmin(admin.ModelAdmin):
    list_display = ['date', 'amount', 'details', 'debit_account', 'credit_account']
    list_filter = ['date', 'debit_account', 'credit_account']
    search_fields = ['details', 'debit_account__name', 'credit_account__name']
    ordering = ['-date']


admin.site.register(Entry, EntryAdmin)
admin.site.register(Account)
