I'm having the following setup in a Django 2 app:
class Base1(models.Model): # ... some fields here... class Meta: abstract = True unique_together = [ 'brand', 'name' ] class Base2(Base1): # ... some more fields here... class Meta: abstract = True class Concrete(Base2): pass
Concrete class doesn't seem to have the
unique_together requirement that's present in
Is this expected? If it is, how can I make sure that
Concrete has the constraint while keeping things DRY?
Try to derive
# ... class Base2(Base1): # ... some more fields here... class Meta(Base1.Meta): abstract = True # ...
See this documentation for meta inheritance.