3

I want to only be able to create new objects on sub-classes and not on base class.

class Product(PolymorphicModel):
    # fields

class ProductType1(Product):
    # fields

class ProductType2(Product):
    # fields

For example in above code creating new objects should only be possible on ProductType1 and ProductType2 and NOT on Product it self.

  • I'd like to know the same thing, so far I've trying using ABC but got metaclass conflict, also tried raising an error in \_\_init\_\_ and \_\_new\_\_ but both raise that error for subclasses instantiations... – Alvaro Rodriguez Scelza Sep 20 '22 at 13:27

0 Answers0