{"version":"1.0","type":"rich","title":"Django ORM subquery example","description":"This example demonstrates how to translate a SQL query into Django’s ORM to filter consignments that are not linked to any booking with a “quote” status. It shows the equivalent raw SQL with nested subqueries and LEFT OUTER JOINs, alongside the Python code using `Consignment.objects.filter()` with `Q` objects and `.exclude()`. The code then prints the status of each resulting consignment’s content object. It relies on Django’s ORM methods `filter`, `exclude`, and `Q`, with the data sourced from logistics and office booking models.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-806a0c5e34df98df9337?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}