diff options
| author | Raphael Michel <mail@raphaelmichel.de> | 2015-06-04 15:09:28 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-06-04 09:40:59 -0400 |
| commit | 3e9b5bfd9c3e16c968278f7d050f52739690eb29 (patch) | |
| tree | 7239a62881432d34e5bf26690d9b3bc7843854c7 /docs/intro/tutorial04.txt | |
| parent | 19e67c6cd13d6442abb2a6eba1b7fba80dcf5457 (diff) | |
Fixed #7060 -- Added a note about race conditions to the tutorial
Diffstat (limited to 'docs/intro/tutorial04.txt')
| -rw-r--r-- | docs/intro/tutorial04.txt | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/docs/intro/tutorial04.txt b/docs/intro/tutorial04.txt index cf622c9aec..2d09de9579 100644 --- a/docs/intro/tutorial04.txt +++ b/docs/intro/tutorial04.txt @@ -179,6 +179,19 @@ Now, go to ``/polls/1/`` in your browser and vote in the question. You should se results page that gets updated each time you vote. If you submit the form without having chosen a choice, you should see the error message. +.. note:: + The code for our ``vote()`` view does have a small problem. It first gets + the ``selected_choice`` object from the database, then computes the new + value of ``votes``, and then saves it back to the database. If two users of + your Web site try to vote at *exactly the same time*, this might go wrong: + The same value, let's say 42, will be retrieved for ``votes``. Then, for + both users the new value of 43 is computed and saved, but 44 would be the + expected value. + + This is called a *race condition*. If you are interested, you can read + :ref:`avoiding-race-conditions-using-f` to learn how you can solve this + issue. + Use generic views: Less code is better ====================================== |
