Run some code after Model Save completes (and after database is updated)

37 views
Skip to first unread message

Spiros Mouzakitis

unread,
Oct 14, 2014, 1:00:18 PM10/14/14
to django...@googlegroups.com
Hi,

-I am looking for an elegant, and universal way to add some code AFTER the saving of a model and after of course the database is updated with changes.
-I have tried post_save signals, but the transaction is still on, the entries do not exist in database
-I have tried overriding save in models.py, but even if i put  the code after.....super(MyModel, self).save(*args, **kwargs), the database is still not updated until the save function completes.

any ideas?

many thanks,
Spiros

Jani Tiainen

unread,
Oct 16, 2014, 12:40:30 AM10/16/14
to django...@googlegroups.com
Database is definitely updated after save has completed and post_save signal is fired.

One thing that may interfere at least MySQL uses "repeatable read" (default) transcation isolation level
meaning that select will return db state when transaction opened. Changing isolation to "read committed"
should improve situation there.

--

Jani Tiainen
Reply all
Reply to author
Forward
0 new messages