Opened 2 years ago
Last modified 2 years ago
#34589 closed Bug
exclude does not support nested ForeignKey relationship — at Version 1
| Reported by: | ftamy9 | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 4.2 |
| Severity: | Normal | Keywords: | 4.1 |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I need to find trips that are not trip__method__title=ShippingChoice.ORGANIZATION
my code is like this:
working_shipments = Shipment.objects.exclude(
state__in=[
ShipmentStateChoices.CANCELLED,
ShipmentStateChoices.DELIVERED
],
trip__method__title=ShippingChoice.ORGANIZATION
).filter(
updated_at__lt=time_threshold,
)
I forced to use a big list on filter instead to use the exclude. my code is like this:
working_shipments = Shipment.objects.exclude(
state__in=[
ShipmentStateChoices.CANCELLED,
ShipmentStateChoices.DELIVERED
]
).filter(
updated_at__lt=time_threshold,
trip__method__title__in=(ShippingChoice.ALO, ShippingChoice.SNAP, ShippingChoice.MIAREH)
)
Note:
See TracTickets
for help on using tickets.
formatted description