1# Preferred alternative to unique_together, Django 2.2+
2# Use the 'constraints' var in class Meta
3class Volume(models.Model):
4 id = models.AutoField(primary_key=True)
5 journal_id = models.ForeignKey(Journals, db_column='jid', null=True, verbose_name="Journal")
6 volume_number = models.CharField('Volume Number', max_length=100)
7 comments = models.TextField('Comments', max_length=4000, blank=True)
8
9 class Meta:
10 constraints = [
11 models.UniqueConstraint(fields=['journal_id', 'volume_number'], name='name of constraint')
12 ]