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
Baking a model with the post_save signal handler returns instance without the update by the handler (which in my case was populating some optional fields if not given).
By studying the codebase I found that the passing _refresh_after_create=True to baker.make fixes the problem.
Alternatively, _refresh_after_create=True could be automatically set if the model is registered a sender of post_save. But this is the idea for another ticket, I guess.
Versions
Python: 3.13
Django 4.1.
Model Bakery 1.20.0
The text was updated successfully, but these errors were encountered:
Describe the issue
Baking a model with the
post_save
signal handler returns instance without the update by the handler (which in my case was populating some optional fields if not given).By studying the codebase I found that the passing
_refresh_after_create=True
tobaker.make
fixes the problem.Expected behavior
I think this functionality should be documented.
I did not find anything on https://model-bakery.readthedocs.io when using the search bar with "_refresh_after_create" query.
Alternatively,
_refresh_after_create=True
could be automatically set if the model is registered a sender ofpost_save
. But this is the idea for another ticket, I guess.Versions
The text was updated successfully, but these errors were encountered: