When I was working on my first Django project, I encountered a problem where modifications done inside pre_save signal were not stored in the database. Back then it took me a couple of hours to figure out what is wrong and how to fix it. I’m sharing what I’ve learned to save that time someone else.
https://mirekdlugosz.com/blog/2025/django-data-modified-in-pre-save-signal-is-not-saved/
@mirekdlugosz I haven't tried this, but I wonder if the `pre_save` signal handler would add items to the `update_fields` parameter. It's passed by reference, so there's a possibility that would work. But it's also super weird and difficult to determine where those updates are happening and something that shouldn't be recommended.
@mirekdlugosz Also, good write up and thank you for sharing!
Good thinking. As far as I remember, something turns `update_fields` into tuple before passing it to signal. And since tuples are immutable, there’s nothing you can do from signal handler.
I mean, given the dynamic nature of Python probably there is something you can do, but that would be extremely obscure and surprising. Definitely not recommended :)
@mirekdlugosz ah, that would make sense!