I’m setting up an exclusion constraint on through model to ensure that we do not accidentally add multiple offerings with overlapping products to an agency. However when i use “reference__fk_id”, I get the error “fk_id” does not exist.
class AgenceSubscription(models.Model): agence = models.ForeignKey(Agence, on_delete=models.CASCADE) sub_group = models.ForeignKey(SubscriptionGroup, on_delete=models.CASCADE) class Meta: ordering = ["agence"] constraints = [ ExclusionConstraint( name="exclude_overlapping_subscriptions", expressions=[ ("agence", RangeOperators.EQUAL), ("sub_group__product_config", RangeOperators.EQUAL), ], ), ]
product_config is a FK to another table.
Aren’t expression allowed on ExclusionConstraint ? Or is this not supported?