TrangPham / django-admin-confirm

AdminConfirmMixin is a mixin for ModelAdmin that adds confirmations to changes, additions and actions.
Other
128 stars 16 forks source link

Move refresh_from_db outside of loop #61

Open StopMotionCuber opened 4 weeks ago

StopMotionCuber commented 4 weeks ago

Fixes

obj.refresh_from_db() is called for every item in a form. In my case that lead to the same query for fetching an object being executed 8 times, even though once would have been enough.

I haven't added an issue for that, as I had the impression adding an issue and adding steps to reproduce were more complicated than just directly fixing the issue.

Tested via:

No tests added, as functionality facing the end user did not change and this is purely a performance related improvement. I could add a unit test checking the amount of queries executed if needed.

Please tell me if more information on this issue is needed or whether this description is sufficient.