title: How to use select_related with GenericForeignKey in django?
body: <p>I have a situation wherein a large number of objects of a particular class are being iterated over, and they take a huge amount of time for processing because I can't pre-select data using <code>select_related</code>. </p>
  
  <p>The class in question goes something like below</p>
  
  <pre><code>from django.contrib.contenttypes.models import ContentType
  from django.db import models
  
  class Offer(models.Model):
      ...
      object_id = models.PositiveIntegerField(db_index = True)
      content_type = models.ForeignKey(ContentType, db_index = True)
      content_object = generic.GenericForeignKey('content_type', 'object_id')
      ...
  </code></pre>
  
  <p>I have tried using select_related like below, but it obviously doesn't work</p>
  
  <pre><code>offerList = Offer.objects.select_related('content_type', "content_object"
      ).filter(content_type=ContentType.objects.get_for_model(SomeObject),
      object_id=someobject.id)
  </code></pre>
  
  <p>So, how can I use <code>select_related</code> with GenericForeignKey in django?</p>