-
Maybe it is possible but i'm trying to exclude/suppress field from inherited module . class CustomerBase(ormar.Model):
class Meta:
abstract = True
customer_name: str = ormar.String(max_length=25,default= lambda : fake.first_name())
filed_to_remove: str = ormar.String(maxlength=2)
class Customer(CustomerBase,ormar.Model):
class Meta(BaseMetaCustomerTrg):
tablename: str = "customer_test"
id: int = ormar.Integer(primary_key=True)
#just an example
filed_to_remove: none= ormar.None() I know i could redefine it as pydantic_only=True in Customer module , |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi, I don't like the idea of None file that has really no use. Your case can be solved by splitting the base: class FieldMixin:
filed_to_remove: str = ormar.String(maxlength=2)
class CustomerBase(ormar.Model):
class Meta:
abstract = True
customer_name: str = ormar.String(max_length=25,default= lambda : fake.first_name())
# you don't have to add ormar.Model (it can even fail mro) as CustomerBase already IS ormar.Model
class Customer(CustomerBase):
class Meta(BaseMetaCustomerTrg):
tablename: str = "customer_test"
id: int = ormar.Integer(primary_key=True)
# this one does not have filed_to_remove: str = ormar.String(maxlength=2)
class CustomerExpanded(FieldMixin, CustomerBase):
class Meta(BaseMetaCustomerTrg):
tablename: str = "customer_test"
id: int = ormar.Integer(primary_key=True)
# now it has also filed_to_remove: str = ormar.String(maxlength=2) |
Beta Was this translation helpful? Give feedback.
-
In 0.10.10 I added the exclude_parent_fields that allows you to skip fields by name coming from parents models |
Beta Was this translation helpful? Give feedback.
In 0.10.10 I added the exclude_parent_fields that allows you to skip fields by name coming from parents models