Hi guys, theres is a way to overriding the save method for inlines form and parent in the same time?
i would like to change the value of a field when the use save the edited inlines form...
Thanks :)
Hi guys, theres is a way to overriding the save method for inlines form and parent in the same time?
i would like to change the value of a field when the use save the edited inlines form...
Thanks :)
One way is to hook into your inline model's `pre_save' signal:
from django.db.models.signals import pre_save
from your_app.models import YourModel
def callback(sender, **kwargs):
# 'instance' is the model instance that is about to be saved,
# so you can do whatever you want to it.
instance.field = new_value
pre_save.connect(callback, sender=YourModel)
But I'm not sure why you can't just override the save
method, which is almost always a better approach.