data = models.Booking.objects.filter(center__isnull=False,org_type='homedx').order_by('-created_at')
return data.order_by( Case(
When ( booking_status="resampling", then=Value(0) ),
When ( booking_status="sample not received", then=Value(1) ),
default = Value(1)
)
)
created_at is DateTimeField in Booking Model. Here i have ordered by choice field and for that i have used Case, When and Value method from django.db.models. But when i am using this it is ignoring order_by created_at. I mean when these two conditions are met. i want to get the data in order of latest date. Why it is not working? Thank you !!