I have a model that takes in a listname. I only want the list name to disable duplicates per user. Currently, a user cannot enter "recipes" twice, but if another user doesn't have a "recipe" list name, they can't enter it either because the field is unique. Is it possible to make the listname only unique to the currently logged in user?
MODEL
class newlist(models.Model):
user = models.ForeignKey(User)
list_name = models.CharField(max_length = 100, unique = True)
picture = models.ImageField(upload_to='profiles/', default = "/media/profiles/default.jpg")
slug = AutoSlugField(populate_from='list_name', default = '')
def __str__(self):
return self.list_name