You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code below I'm writing a custom serializer for list[int] fields. In the serializer I need to know the tag name of the field, rather than the field name. These are not the same because tag names contain dashes (-), so I had to rename them:
importpydantic_xmlaspxmlclassModel(pxml.BaseXmlModel):
x_ids: list[int] =pxml.element(tag="x-ids")
y_ids: list[int] =pxml.element(tag="y-ids")
@pxml.xml_field_serializer("x_ids", "y_ids")def_serialize_ids(self, elem, value, field):
# need the tag name ("x-ids" or "y-ids") here
What is the recommended way to get the tag name?
The text was updated successfully, but these errors were encountered:
In the code below I'm writing a custom serializer for
list[int]
fields. In the serializer I need to know the tag name of the field, rather than the field name. These are not the same because tag names contain dashes (-
), so I had to rename them:What is the recommended way to get the tag name?
The text was updated successfully, but these errors were encountered: