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
I can create an empty instance of Config, that I can populate with values until validation is required:
conf = Config()
db = DatabaseConfig()
At this point I can assign values to all the fields of db, But I cannot assign db itself to the corresponding field in config:
In [12]: conf.db = db
ValidationError: ("Error for field 'db'.", ValidationError("Error for field 'base_url'.", ValidationError('Field is required!',)))
While I understand why this is happening (fields validates values on assignment in __set__, and in the case of EmbeddedField this means calling validate on the embedded field), this is very annoying since I have to pre-initialize all the embedded fields beforehand.
I think it would be better to defer the validation of EmbeddedField until validate is called on the containing model.
The text was updated successfully, but these errors were encountered:
Consider the following model:
I can create an empty instance of
Config
, that I can populate with values until validation is required:At this point I can assign values to all the fields of
db
, But I cannot assigndb
itself to the corresponding field inconfig
:While I understand why this is happening (fields validates values on assignment in
__set__
, and in the case ofEmbeddedField
this means callingvalidate
on the embedded field), this is very annoying since I have to pre-initialize all the embedded fields beforehand.I think it would be better to defer the validation of
EmbeddedField
untilvalidate
is called on the containing model.The text was updated successfully, but these errors were encountered: