title: How to filter generic foreign keys?
body: <p>I have these models:</p>
  
  <pre><code>class EventEntry(models.Model):
      content_type = models.ForeignKey(ContentType)
      object_id = models.PositiveIntegerField()
      content_object = generic.GenericForeignKey('content_type', 'object_id')
      start_date =  models.DateTimeField(...)
      end_date = models.DateTimeField(...)
      field = models.CharField(max_length=64)
  
  class ObjectPerm(models.Model):
      content_type = models.ForeignKey(ContentType)
      object_id = models.PositiveIntegerField()
      content_object = generic.GenericForeignKey('content_type', 'object_id')
      public = models.BooleanField(...)
      users = models.ManyToManyField(User...)
      groups = models.ManyToManyField(Group...)
  
  class Meeting(models.Model):
      scheduled_time = generic.GenericRelation(EventEntry)
      room = models.CharField(max_length=8)
      permissions = GenericRelation(ObjectPerm)
  
  class Milestone(models.Model):
      due_date = generic.GenericRelation(EventEntry)
      title = models.CharField(max_length=128)
      permissions = GenericRelation(ObjectPerm)
  </code></pre>
  
  <p>The EventEntry class is used to attach scheduling information to any object, such as Meeting and Milestone.</p>
  
  <p>The ObjectPerm class provides object level permissions to any model that needs protection.</p>
  
  <p>When I create an instance of Meeting, I assign an EventEntry instance for the schedule information. I also assign ObjectPerm instances to specify which users can access the meeting object.</p>
  
  <p>There are more models like Meeting and Milestone.</p>
  
  <p>Now, what I want to do is retrieve EventEntry instances, but only those for related objects the user has permission to access, based on the ObjectPerm model.</p>
  
  <p>For example all EventEntry instances where public == True or the user is in the EventEntry field "users". This way I can pull out all the events to display in a calendar but I don't need to filter the meetings, milestones etc. Except I can't work out how to write this filter in Python using Django's ORM.</p>