title: django intermediate model with no foreign key error
body: <p>Building some complex models for my django app and got some help here:</p>
  
  <p><a href="https://stackoverflow.com/questions/37979749/using-manytomany-through-correctly-for-complex-model-in-django/37980278?noredirect=1#comment63450091_37980278">Using ManyToMany through correctly for complex model in django</a></p>
  
  <p>To which the result was getting this far here:</p>
  
  <blockquote>
    <p>ipaswdb.ProviderLocations: (fields.E336) The model is used as an
    intermediate model by 'ipaswdb.Group.providers', but it does not have
    a foreign key to 'Group' or 'Provider'.</p>
  </blockquote>
  
  <p>I mean yes the error is i n english but I do not know what it is really trying to tell me.</p>
  
  <p>Full models below, but the idea was to have A group having many locations.</p>
  
  <p>A provider belonging to a group via whichever location(s) they work at, secondly a provider can belong to many groups at many locations</p>
  
  <pre><code>Provider A -&gt; location 1
           -&gt; location 2
           -&gt; location 3
  
  Group 1 -&gt; has a location 1
          -&gt; has a location 2
  
  Group 2 -&gt; has a location 3
          -&gt; has a location 4
  </code></pre>
  
  <p>Provider A belongs to group 1 and 2 via locations 1,2,3</p>
  
  <p>My full models are:</p>
  
  <pre><code>class Group(models.Model):
      group_name = models.CharField(max_length=50)
  
      created_at=models.DateField(auto_now_add=True)
      updated_at=models.DateField(auto_now=True)
      providers = models.ManyToManyField('Provider', through='ProviderLocations')
  
  
  
  
  class Provider(models.Model):
      first_name = models.CharField(max_length = 50)
  
      created_at=models.DateField(auto_now_add=True)
      updated_at=models.DateField(auto_now=True)
  
  
  
  class ProviderLocations(models.Model):
      provider = models.ForeignKey('Provider', on_delete=models.CASCADE)
      group_location = models.ForeignKey('GroupLocations', on_delete=models.CASCADE)
      created_at=models.DateField(auto_now_add=True)
      updated_at=models.DateField(auto_now=True)
  
  class GroupLocations(models.Model):
      address = models.ForeignKey('Address', on_delete= models.SET_NULL, null=True)
      group = models.ForeignKey('Group', on_delete=models.SET_NULL, null=True)
      doing_business_as = models.CharField(max_length = 255)
      created_at=models.DateField(auto_now_add=True)
      updated_at=models.DateField(auto_now=True)
  </code></pre>
  
  <p>I tried an edit on the ProviderLocations too with no results:</p>
  
  <pre><code>class ProviderLocations(models.Model):
      provider = models.ForeignKey('Provider', on_delete=models.CASCADE)
      group = models.ManyToManyField('Group', through='GroupLocations')
      created_at=models.DateField(auto_now_add=True)
      updated_at=models.DateField(auto_now=True)
  </code></pre>