2

How do you include in Django's meta unique_together a field from a related model where that field is a foreignkey? And can that field from the related model be part of a primary key?

Here is the code,

class A(models.Model):
    field1 = models.CharField()

    class Meta:
        unique_together = ('field1') # can I add field2 here 

class B(models.Model):
    field2 = models.ForeignKey('A')
bootstrapman
  • 109
  • 10

0 Answers0