Как я могу объявить составное ограничение как эта схема в Django 3 модели?
Я пытался объявить внешний и первичный ключ, как это:
class DiAttribute(models.Model):
attribute_name = models.CharField(max_length=80, blank=True, null=True)
attribute_id = models.IntegerField(max_length=10, blank=False, null=False, unique=True, related_name='attribute_id')
object_type_id = models.CharField(max_length=50, blank=False, null=False, unique=True, related_name='object_type_id')
class Meta:
managed = False
unique_together = (('object_id', 'attribute_no'),)
db_table = 'di_attribute'
class Attribute(models.Model):
object_id = models.ForeignKey(RpObject, on_delete=models.DO_NOTHING, db_column='object_id')
attribute_no = models.IntegerField(max_length=10, blank=False, null=False)
attribute_id = models.ForeignKey(DiAttribute, on_delete=models.DO_NOTHING, db_column='attribute_id', to_field='attribute_id', unique=True, related_name='attribute_id')
object_type_id = models.ForeignKey(DiAttribute, on_delete=models.DO_NOTHING, db_column='object_type_id', to_field='object_type_id', unique=True, related_name='object_type_id')
class Meta:
managed = False
unique_together = (('object_id', 'attribute_no'),)
db_table = 'attribute'
но это не работает