Simultanous AJAX requests and MySQL database data visibility in Django
I have solved this issue by wrapping my view in the @transaction.autocommit decorator and executing transaction.commit() immediately before checking in the database if an answer with a particular client_id exists. This accomplishes the "refresh" I was aiming for.
I have a Django app with a MySQL database which allows answering of questions on an HTML page. The answers get sent to the server via AJAX calls. These calls are initiated by various JavaScript events and can often be fired multiple times for one answer. When this happens, multiple save requests for one answer get sent to the server.
In order to avoid duplicate answers, each answer has a client-side ID generated the first time it gets saved - client_id. Before creating a new answer server-side, the Django app first checks the DB to see if an answer with such a client_id exists. If one does, the second save requests updates the answer instead of creating a new one.
In Chrome, when a text input field is focused, and the user clicks outside of the Chrome window, two save requests get fired one after the other. The server receives them both. Let's say that for the sake of the example the client_id is 71.
The first request checks the DB and sees that no answers with a client_id 71 exist. It creates a new answer and saves in the the DB. I am debugging with breakpoints and at this time, I see in my external MySQL database viewer that indeed the answer is saved. In my IDE, when I execute Answer.objects.filter(client_id=71) I get the answer as well. I let the debugger continue.
Immediately my second breakpoint fires for the second AJAX save answer request. Now a curious thing happens. In my IDE, when I execute Answer.objects.filter(client_id=71) I see no answers! My external tool confirms that the answer is there. So my code creates a new answer and saves it. Now if in my IDE I execute Answer.objects.filter(client_id=71) I see two answers with that client_id. 
I am guessing that the DB connection or MySQL uses some kind of time-based method of keeping views constant, but it is causing me problems here. I would like a live insight into the state of the DB.
I am not using any transaction management, so Django should be doing auto_commit.
How can I instruct the DB connect to "refresh" or "reset" itself to take into consideration data which is actually in the DB?