title: Django many to many avoiding duplication
body: <p>I'm getting duplication in my path (many to many) table, and would like it only to contain unique items. </p>
  
  <p>models.py</p>
  
  <pre><code>class Image(models.Model):
      path = models.CharField(max_length=128)
  
  class User(models.Model):
      username = models.CharField(max_length=32)
      created = models.DateTimeField()
      images = models.ManyToManyField(Image, through='ImageUser')
  
  class ImageUser(models.Model):
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      image = models.ForeignKey(Image, on_delete=models.CASCADE)
  </code></pre>
  
  <p>But, I seem to be able to create more than one image with the same path. I would like one unique image path to point to multiple users without having duplicate images in the Image table. </p>
  
  <pre><code>u = User.objects.create(username='AndyApple')
  i = Image(path='img/andyapple.jpg')
  i.save()
  ui = ImageUser(user=u, image=i)
  ui.save()
  
  u2 = User.objects.create(username='BettyBanana')
  ui = ImageUser(user=u2, image=i)
  </code></pre>
  
  <p>This seems to create two rows in the images table for the same image. The docs suggest this should not happen <a href="https://docs.djangoproject.com/en/1.9/ref/models/fields/#django.db.models.ManyToManyField.through" rel="nofollow">ManyToManyField.through</a></p>
  
  <p>Thanks!</p>