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 have a Django change form with a few inlines. I have created a actions_submit_line action that basically updates the status field in the model object and sends an email. The email is generated using the content from both parent and inline/child model fields. However, the email is missing the fields from the child model.
On further digging into the unfold repo, I noticed that the actions are called from the save_model function and as per the django's core implementation save_related is called after the save_model which explains why the related model fields are not present/saved when the email is sent.
Currently I am overriding the save_model and save_related in my modeladmin to workaround this issue.
def save_model(self, request, obj, form, change) -> None:
obj.save()
def save_related(self, request, form, formsets, change):
super().save_related(request, form, formsets, change)
for action in self.get_actions_submit_line(request):
if action.action_name not in request.POST:
continue
action.method(request, form.instance)
Should this be part of the unfold's core functionality, if not, what's the argument against it?
The text was updated successfully, but these errors were encountered:
I agree with you.
The logic behind the design is to execute the submit-line actions after the object is saved, along with which one implication is that all the relations should also be saved as well.
I have a Django change form with a few inlines. I have created a actions_submit_line action that basically updates the
status
field in the model object and sends an email. The email is generated using the content from both parent and inline/child model fields. However, the email is missing the fields from the child model.On further digging into the unfold repo, I noticed that the actions are called from the
save_model
function and as per the django's core implementationsave_related
is called after thesave_model
which explains why the related model fields are not present/saved when the email is sent.Currently I am overriding the
save_model
andsave_related
in my modeladmin to workaround this issue.Should this be part of the unfold's core functionality, if not, what's the argument against it?
The text was updated successfully, but these errors were encountered: