I have a model Booking which has a history in it. like this and I use django_simple_history
class Booking(CreatedAtAbstractBase):
history = HistoricalRecords()
And I use a management command to do tasks. In that I wanted to Prefetch history when taking a booking
booking_p_history = Booking.history.filter(s_id=6).order_by(
'updated_at').first()
booking_obj_list = Booking.objects.select_related(...) \
.prefetch_related(
Prefetch('booking_history', queryset=booking_p_history, to_attr='driver_pickup_history')
,'booking_history') \
.filter(...)
How to use simple history inside prefetch?