While we have improved upon the base admin interface quite a bit just by showing the relevant fields on the list page, we can do more. Let's look at some actions that an administrator might want to take for the booking enquiries that the site receives:
Viewing only the booking enquiries that have been approved or the ones that have not yet been approved
Searching for a booking by customer name
Approving or not approving a booking enquiry quickly
Selecting multiple booking enquiry objects and sending e-mails to the customers about their approval/disapproval
For our first feature, we want to allow the user filtering on the displayed objects. There should be a filter on the page that allows them to see only bookings that have been approved or not approved. To do so, the Django admin provides you with a list_filter
attribute on the ModelAdmin
subclass. The list_filter
attribute holds a list of fields that you can filter on. In our BookingModelAdmin
class...