djangosnippets.org: Latest snippets tagged with 'subquery'https://djangosnippets.org/tags/subquery/2021-08-26T06:45:03.783842-05:00PostgreSQL JSON subqueries
2021-08-26T06:45:03.783842-05:00dolamrothhttps://djangosnippets.org/snippets/10860/<h4>Allows to fetch a row or array of rows of data, linked to parent object, in a single query. Data is fetched as JSON and is not serialized into Django objects.</h4>
<h5>Example:</h5>
<pre><code>from django.db import Models
class Book(models.Model):
authors = models.ManyToMany('Author', through='BookToAuthor', blank=True)
title = models.CharField(max_length=512, default='')
class Author(models.Model):
name …</code></pre>
Freely redistributable