Code

Ticket #5681: patch5681-1.diff

File patch5681-1.diff, 1.1 KB (added by cornel, 5 years ago)
Line 
1Index: django/contrib/admin/options.py
2===================================================================
3--- django/contrib/admin/options.py     (revision 10689)
4+++ django/contrib/admin/options.py     (working copy)
5@@ -801,10 +801,7 @@
6 
7         if obj is None:
8             raise Http404(_('%(name)s object with primary key %(key)r does not exist.') % {'name': force_unicode(opts.verbose_name), 'key': escape(object_id)})
9-
10-        if request.method == 'POST' and request.POST.has_key("_saveasnew"):
11-            return self.add_view(request, form_url='../../add/')
12-
13+       
14         ModelForm = self.get_form(request, obj)
15         formsets = []
16         if request.method == 'POST':
17@@ -826,6 +823,8 @@
18                 formsets.append(formset)
19 
20             if all_valid(formsets) and form_validated:
21+                if request.POST.has_key("_saveasnew"):
22+                    return self.add_view(request, form_url='../../add/')
23                 self.save_model(request, new_object, form, change=True)
24                 form.save_m2m()
25                 for formset in formsets: