We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can i do this?
class Gateway(Model): serial_number: str name: str ip: IPv4Address devices: Optional[List[PeripheralDvice]] = Field(max_items=10) class Config: json_encoders = {IPv4Address: lambda v: str(v)}
The text was updated successfully, but these errors were encountered:
Normally, since Pydantic already handle this field type, you shouldn't have to specify those json_encoders.
json_encoders
from odmantic import Model from ipaddress import IPv4Address class Gateway(Model): ip: IPv4Address g = Gateway(ip=IPv4Address("192.168.0.1")) assert g.json() == '{"ip": "192.168.0.1", "id": "..."}'
However, if you need custom json_encoders, you're right. It's currently not working. I'll release a patch soon.
Sorry, something went wrong.
Might be related to pydantic/pydantic#2024
Successfully merging a pull request may close this issue.
How can i do this?
The text was updated successfully, but these errors were encountered: