title: Query the contents of a Django model's JSONField
body: <p>I'm trying to figure out a way to query the data inside a postgres JSONField on a particular instance of my model. </p>
  
  <p>From what I've seen, all the use cases are for things the equivalent of if you had an attributes JSONField, and then selecting all instances of your model where attributes ->> color = 'red' or whatever.</p>
  
  <p>So let's give this a more real example, let's say we have a model <code>Shoe</code> and it has price and quantity and whatever as fields, but then also a JSONField called <code>versions</code>, which is an array of objects, each objects having the things that make each version special. </p>
  
  <p>So if one instance of the Shoe model is Air Jordans, the attributes JSONField could look like:</p>
  
  <pre><code>[ 
      { 
          color: black, 
          edition: limited, 
          tongueColor: red 
      }, 
      { 
          color: black, 
          edition: standard 
      }, 
      { 
          color: gold, 
          edition: fancy, 
          bright: very 
      } 
  ]
  </code></pre>
  
  <p>So there's two things we can do, we can:</p>
  
  <ol>
  <li>Query the Model for all shoes that have an available version with color: black (which would return our Air Jordans, plus maybe other shoes), or</li>
  <li>Query the instance of the model for all objects inside the JSONField versions where color = black. So if we already had <code>Shoe.objects.filter(name='Air Jordans')</code> or something, could tack on some method or something at the end to just return the first two objects above where <code>color == black</code>?</li>
  </ol>
  
  <p>I can find examples online of doing the first, but not the second.</p>
  
  <p>I could just bring the object into memory and filter from there, but this JSONField is where I was hoping to store very large quantities of arbitrary data, and so being able to query without bringing the whole blob into memory is fairly important. Can JSONField support this?</p>