title: Django generic relations practice
body: <p>i'm developing a authentication backend with object-based permissions for my django-app.I use generic relations between an object and a permission:</p>
  
  <pre><code>class GroupPermission(models.Model):
      content_t= models.ForeignKey(ContentType,related_name='g_content_t')
      object_id = models.PositiveIntegerField()
      content_object = generic.GenericForeignKey('content_t', 'object_id')
      permission=models.ForeignKey(Permission)
      group = models.ForeignKey(Group)
  </code></pre>
  
  <p>And now i want to get all objects of a specified content type for which a сertain group or user has a сertain permission. What's the best way to do that?
  Shall i define the second end of the relation in the app's models? or better write custom sql?
  I'm trying to build a generic backend so i don't want it to depend on the app that is using it.
  Thanks! </p>