The by_alias=True parameter for the dict() and model_dump() functions is not selecting the alias in a class derived from rx.Model correctly. #3358
aden-collector
announced in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We are using reflex version 0.5.0post1. Our code used the dict() function with by_alias=True to get a dictionary from an object of a data class. The data class inherited from rx.Base and has a few field names. This is a sample field definition: name: str = Field(alias="Name"). Function dict() worked in the past but stopped working recently. The key value in the resulting dictionary was "name" instead of the alias "Name". We heard that function dict() was deprecated so we tried using the model_dump() function with the parameter by_alias=True. We changed the data class to inherit from rx.Model instead of rx.Base. The dictionary returned by model_dump() doesn't use the alias. We have the same issue as using the dict() function (key name "name" in the dictionary instead of the alias "Name")
Beta Was this translation helpful? Give feedback.
All reactions