[Django]-Django: Making a value in a model unique specific to a user

4👍

unique_together is probably what you are looking for.

class Project(models.Model):

    name = models.CharField(max_length=200)
    user = models.ForeignKey(User, on_delete=models.CASCADE)

    class Meta:
        unique_together = (('name', 'user'),)
👤iri

Leave a comment