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
Describe your issue
It seems that due to the nature that submit line actions are executed when model is saved, but before inline forms were saved, it's impossible to specify an action that for example will use both the main model, and it's children, as children data is not saved yet.
For example in my use case I had main model as read only page, and user needed to edit inline admin models in another tab, after editing I wanted to save & send API request to another server with new data entered in model inlines. However in my testing I found out that inline data was empty, at the time when I tried to initiate API request, but was saved after submit line action was executed. It happens only for the first time when data is empty, second time it will work, but I assume it would use old data, not the one that was submitted last.
I checked underlying django code for this, I assume the reason could be that submit line actions are happening in save_model method which saves only the main model, Django invokes another save_related method which saves additional formset data. It seems that in order for this to work properly, submit line actions should execute after both save_model and save_related methods have been executed.
The text was updated successfully, but these errors were encountered:
alenzeinolov
changed the title
Submit line actions are executed before inline formsets are saved
fix: submit line actions are executed before inline formsets are saved
Jan 16, 2025
What version of Unfold are you using?
0.44.0
What version of Django are you using?
5.1
What browser are you using?
Not browser related
Did you checked changelog/commit history, if the bug is not already fixed?
Yes
Did you searched other issues, if the bug is not already fixed?
Yes
Did you checked documentation?
Yes
Are you able to replicate the bug in the demo site?
No, only usage of submit line actions I found was here https://demo.unfoldadmin.com/en/admin/formula/constructor/33/change/, but this admin page does not have any inlines.
Describe your issue
It seems that due to the nature that submit line actions are executed when model is saved, but before inline forms were saved, it's impossible to specify an action that for example will use both the main model, and it's children, as children data is not saved yet.
For example in my use case I had main model as read only page, and user needed to edit inline admin models in another tab, after editing I wanted to save & send API request to another server with new data entered in model inlines. However in my testing I found out that inline data was empty, at the time when I tried to initiate API request, but was saved after submit line action was executed. It happens only for the first time when data is empty, second time it will work, but I assume it would use old data, not the one that was submitted last.
I checked underlying django code for this, I assume the reason could be that submit line actions are happening in
save_model
method which saves only the main model, Django invokes anothersave_related
method which saves additional formset data. It seems that in order for this to work properly, submit line actions should execute after bothsave_model
andsave_related
methods have been executed.The text was updated successfully, but these errors were encountered: