Uhm... but this code is run in a transaction, I expected this to implicitly lock the table. What is the isolation level   of the Django connection? If we really need to lock the table, how would you do that? By changing the isolation level or by using LOCK TABLE table_name IN ACCESS EXCLUSIVE MODE?