webflow / webflow-python

7 stars 4 forks source link

`CollectionItemFieldData` object does not give access to custom keys / values #12

Open barapa opened 6 months ago

barapa commented 6 months ago

Only name and slug are available.

class CollectionItemFieldData(pydantic.BaseModel):
    name: typing.Optional[str] = pydantic.Field(description="Name of the Item")
    slug: typing.Optional[str] = pydantic.Field(
        description="URL structure of the Item in your site. Note: Updates to an item slug will break all links referencing the old slug."
    )
co-odw commented 1 month ago

For anyone interested. Here is a temporary workaround..

# Monkey patch CollectionItemFieldData to support extra config (necessary to
# retrieve pydantic.Extra.allow reference from same pydantic reference used by
# webflow)
try:
    import pydantic.v1 as pydantic
except ImportError:
    import pydantic
from webflow import CollectionItemFieldData
CollectionItemFieldData.Config.extra = pydantic.Extra.allow