I need your help for a particular query
I have a list of missions, a mission is a package of one or more service offers and a service offer is a service with customer specific parameters (price, duration, ...) and I want to filter missions on a service.
Example:
Missions :
[
name : 010101
Service offers labels : facelift, painting
date : 08/22/2015 2:00pm
]
[...]
If I search all missions with "facelift" service like this :
Mission.objects.select_related('costumer')
.prefetch_related(
Prefetch(
'service_offers',
queryset = ServiceOffer.objects.select_related('service')
.filter(service__name__exact = "facelift")
)
)
The result will be
name : Mission 1
Service offers labels : facelift
date : 08/22/2015 2:00pm
but I want
name : Mission 1
Service offers labels : facelift, painting
date : 08/22/2015 2:00pm
service_offers
to just thefacelift
ones? Remove the custom queryset for thePrefetch
. Otherwise it's difficult to tell what you are looking for here. – Kevin Brown Aug 22 '15 at 21:46