title: Intermediate table with generic foreign key
body: <p>I'm trying to replace a field in an intermediate table with a generic field. Using Django 1.6, MariaDB/MySQL.</p>
  
  <p>I have a class (PermissionGroup) that links a resource to a group. Works fine. However I have several other tables that are similar - linking some id to a group id.</p>
  
  <p>I thought I could replace these tables with one table that uses a generic foreign key, along with the group id. However this does not validate.</p>
  
  <p>Here's the original, which works:</p>
  
  <pre><code># core/models.py
      class PermissionGroup(models.Model):
          resource = models.ForeignKey('core.Resource')
          group = models.ForeignKey('auth.Group')
  
      class Resource(models.Model):
          groups = models.ManyToManyField('auth.Group', through='core.PermissionGroup')
  
  
  # auth/models.py
      class Group(models.Model):
          name = models.CharField(max_length=80, unique=True)
  </code></pre>
  
  <p>Now, trying to change the PermissionGroup to use a GenericForeignKey:</p>
  
  <pre><code># core/models.py
      class PermissionGroup(models.Model):
          content_type = models.ForeignKey('contenttypes.ContentType')
          object_id = models.PositiveIntegerField()
          content_object = generic.GenericForeignKey()
          group = models.ForeignKey('auth.Group')
  
      class Resource(models.Model):
          groups = models.ManyToManyField('auth.Group', through='core.PermissionGroup')
  
  # auth/models.py
      class Group(models.Model):
          name = models.CharField(max_length=80, unique=True)
  </code></pre>
  
  <p>The django model validation now fails with:</p>
  
  <p>core.resource: 'groups' is a manually-defined m2m relation through model PermissionGroup, which does not have foreign keys to Group and Resource</p>
  
  <p>Is this simply not possible, or is another means to accomplish this?</p>