From 61b9c8fe005d6d2a5a907b4402ce09b4b8153dad Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Fri, 29 Feb 2008 21:39:13 +0000 Subject: [PATCH] newforms-admin: Fixed #5735. Wrapped save_add and save_change with commit_on_success to ensure data consistency if an inline fails to save. Thanks, Honza Kral. git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@7188 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/options.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 3778995d7b..6c33b6e15e 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -5,7 +5,7 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.admin import widgets from django.contrib.admin.util import get_deleted_objects from django.core.exceptions import ImproperlyConfigured, PermissionDenied -from django.db import models +from django.db import models, transaction from django.http import Http404, HttpResponse, HttpResponseRedirect from django.shortcuts import get_object_or_404, render_to_response from django.utils.html import escape @@ -401,6 +401,7 @@ class ModelAdmin(BaseModelAdmin): else: post_url = '../../../' return HttpResponseRedirect(post_url) + save_add = transaction.commit_on_success(save_add) def save_change(self, request, model, form, formsets=None): """ @@ -451,6 +452,7 @@ class ModelAdmin(BaseModelAdmin): else: request.user.message_set.create(message=msg) return HttpResponseRedirect("../") + save_change = transaction.commit_on_success(save_change) def render_change_form(self, request, model, context, add=False, change=False, form_url='', obj=None): opts = model._meta