title: In Django, how to index a field on a proxy model's original model?
body: <p>I have a model that is a proxy model based on <a href="https://github.com/django/django-contrib-comments" rel="nofollow noreferrer">Django Comments'</a> <code>Comment</code> model:</p>
  
  <pre class="lang-py prettyprint-override"><code>from django_comments.models import Comment
  
  class Annotation(Comment):
  
      # ...
  
      class Meta:
          proxy = True
  </code></pre>
  
  <p>The <code>Comment</code> model has a <code>TextField()</code> called <code>comment</code> and I'd like to add a <a href="https://docs.djangoproject.com/en/2.1/ref/contrib/postgres/indexes/#ginindex" rel="nofollow noreferrer">GinIndex</a> to this to speed up full text searching using Postgresql.</p>
  
  <p>However, I can't add an index on this field in <code>Annotation</code>'s <code>Meta</code> class because I get this error:</p>
  
  <blockquote>
    <p>annotations.Annotation: (models.E016) 'indexes' refers to field 'comment' which is not local to model 'Annotation'.<br>
      HINT: This issue may be caused by multi-table inheritance.</p>
  </blockquote>
  
  <p>And I can't add an index to the field definition itself, because it's in <code>django_comments</code>' <code>Comment</code> model.</p>
  
  <p>I <em>guess</em> I could write a migration to manually add an index to <code>django_comments.models.Comment</code>'s <code>comment</code> field using SQL, but I wonder if there's some less messy way that I'm missing?</p>