I have a model that looks like the following:
class LibraryEntry(models.Model):
host_lib_song_id = models.IntegerField()
song = models.CharField(max_length=200)
artist = models.CharField(max_length=200)
album = models.CharField(max_length=200)
owning_user = models.ForeignKey(User)
is_deleted = models.BooleanField(default=False)
Now, if I so a select where is_deleted=False, the combination of host_lib_song_id and owning_user should be unique. How can I express this?
Overriding
validate_uniqueto check the uniqueness ifis_deletedisFalseis more appropriate: