Is there a way to define a couple of fields as unique in Django?
I have a table of volumes (of journals) and I don't want more then one volume number for the same journal.
class Volume(models.Model):
id = models.AutoField(primary_key=True)
journal_id = models.ForeignKey(Journals, db_column='jid', null=True, verbose_name = "Journal")
volume_number = models.CharField('Volume Number', max_length=100)
comments = models.TextField('Comments', max_length=4000, blank=True)
I tried to put unique = True
as attribute in the fields journal_id
and volume_number
but it doesn't work.