[codestyle] shortly explain why we wrap .create()
in a transaction
This commit is contained in:
parent
aa5d19c5e5
commit
246c22ce39
1 changed files with 2 additions and 0 deletions
|
@ -48,6 +48,8 @@ class DetailView(generic.DetailView):
|
|||
@require_http_methods(["POST"])
|
||||
def enter(request: HttpRequest) -> HttpResponse:
|
||||
try:
|
||||
# if .create() failed, the transaction is rolled back and we are in a
|
||||
# clean (database) state to handle exceptions
|
||||
with transaction.atomic():
|
||||
teil = Teil.objects.create(name=request.POST["new_name"])
|
||||
except Exception:
|
||||
|
|
Loading…
Add table
Reference in a new issue