I've got a snippet of code such as this inside a Django application

def update_account(user_account,add_widget_count):
    user_account.add_widgets(add_widget_count)
    user_account.save()

    notify_other_system_about_account_update(user_account)

After I run this included in my application, everything is effective. Particularly, when my other system (exterior to django) obtain the notification, it inspections the database, and also the widget count is up-to-date.

However, after i run the above mentioned code in the admin website, there's an problem. When my other system will get the notification, it doesn't begin to see the up-to-date value within the database. I confirm by putting a breakpoint and checking within the database and it doesn't get up-to-date following the call to .save() - within the non-admin-site call the DB is up-to-date after i check throughout this breakpoint. Only once i allow the application run its course, does the DB get up-to-date.

May be the django admin middleware doing a bit of kind of stalling or deferring od DB creates?

Update

I even moved the phone call to notify_other_system_about_account_update(user_account) to some publish_save signal handler on my small UserAccount object. The signal fires, however when I recieve it. The database updates sooner or later after my signal handler returns. This behavior only happens if running from inside the admin website.

I discovered the problem. The django admin uses view-wide DB transactions. I have to by hand commit the transaction before notifying the exterior system