diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 0365228..424c512 100644
a
|
b
|
class ModelAdmin(BaseModelAdmin):
|
495 | 495 | inline_formsets = [] |
496 | 496 | if request.method == 'POST': |
497 | 497 | form = ModelForm(request.POST, request.FILES) |
| 498 | if form.is_valid(): |
| 499 | obj = form.save(commit=False) |
| 500 | else: |
| 501 | obj = None |
498 | 502 | for FormSet in self.formsets_add(request): |
499 | | inline_formset = FormSet(data=request.POST, files=request.FILES) |
| 503 | inline_formset = FormSet(instance=obj, data=request.POST, files=request.FILES) |
500 | 504 | inline_formsets.append(inline_formset) |
501 | | if all_valid(inline_formsets) and form.is_valid(): |
| 505 | if all_valid(inline_formsets) and obj: |
502 | 506 | return self.save_add(request, model, form, inline_formsets, '../%s/') |
503 | 507 | else: |
504 | 508 | form = ModelForm(initial=request.GET) |
… |
… |
class ModelAdmin(BaseModelAdmin):
|
554 | 558 | inline_formsets = [] |
555 | 559 | if request.method == 'POST': |
556 | 560 | form = ModelForm(request.POST, request.FILES) |
| 561 | if form.is_valid(): |
| 562 | new_obj = form.save( commit=False ) |
| 563 | else: |
| 564 | new_obj = obj |
| 565 | |
557 | 566 | for FormSet in self.formsets_change(request, obj): |
558 | | inline_formset = FormSet(obj, request.POST, request.FILES) |
| 567 | inline_formset = FormSet(new_obj, request.POST, request.FILES) |
559 | 568 | inline_formsets.append(inline_formset) |
560 | 569 | |
561 | 570 | if all_valid(inline_formsets) and form.is_valid(): |