title: django orm group by json key in json field
body: <p>I'm using json field on my django model:</p>
  
  <pre><code>class JsonTable(models.Model):
      data = JSONField()
      type = models.IntegerField()
  </code></pre>
  
  <p>I tried next query, which works for normal sql fields:</p>
  
  <pre><code>JsonTable.objects.filter(type=1).values('type').annotate(Avg('data__superkey'))
  </code></pre>
  
  <p>But this throws next error:</p>
  
  <pre><code>FieldError: Cannot resolve keyword 'superkey' into field. Join on 'data' not permitted.
  </code></pre>
  
  <p><strong>Is there way to make group by on json key, using Django ORM or some python lib, without use of raw sql?</strong></p>
  
  <p>Versions: Django 1.9b, PostgreSQL 9.4</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Example 2:</p>
  
  <pre><code>JsonTable.objects.filter(type=1).values('data__happykey').annotate(Avg('data_superkey'))
  </code></pre>
  
  <p>throws same error on <code>happykey</code></p>