“Django Unique_together” Code-Antworten

Django Unique_together

# Preferred alternative to unique_together, Django 2.2+
# Use the 'constraints' var in class Meta 
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)

    class Meta:
        constraints = [
            models.UniqueConstraint(fields=['journal_id', 'volume_number'], name='name of constraint')
        ]
Bloody Batfish

Unique_together, was davon in Django verwendet wird

unique_together = [['driver', 'restaurant']]
Evil Eagle

Ähnliche Antworten wie “Django Unique_together”

Fragen ähnlich wie “Django Unique_together”

Weitere verwandte Antworten zu “Django Unique_together” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen