Avoiding race condition between validation for uniqueness and insertion
问题 I have a Django 1.7 beta 1 project with a standard user signup form. Conceptually, it makes sense for the form validation to fail if the username is already taken. However, the form validation and the saving of the successfully created user model are separate steps, so there's a race condition where the validation can pass but the actual user.save() can fail with an IntegrityError . I'm unclear on what happens if both the form validation and the user.save() step are wrapped in the same