diff -r df0e563861bd contrib/admin/options.py
a
|
b
|
|
478 | 478 | ModelForm = self.get_form(request) |
479 | 479 | formsets = [] |
480 | 480 | if request.method == 'POST': |
481 | | form = ModelForm(request.POST, request.FILES) |
| 481 | if isinstance(ModelForm, ModelFormMetaclass): |
| 482 | form = ModelForm(request.POST, request.FILES) |
| 483 | else: |
| 484 | form = ModelForm |
482 | 485 | if form.is_valid(): |
483 | 486 | form_validated = True |
484 | 487 | new_object = self.save_form(request, form, change=False) |
… |
… |
|
509 | 512 | continue |
510 | 513 | if isinstance(f, models.ManyToManyField): |
511 | 514 | initial[k] = initial[k].split(",") |
512 | | form = ModelForm(initial=initial) |
| 515 | if isinstance(ModelForm, ModelFormMetaclass): |
| 516 | form = ModelForm(initial=initial) |
| 517 | else: |
| 518 | form = ModelForm |
513 | 519 | for FormSet in self.get_formsets(request): |
514 | 520 | formset = FormSet(instance=self.model()) |
515 | 521 | formsets.append(formset) |
… |
… |
|
564 | 570 | ModelForm = self.get_form(request, obj) |
565 | 571 | formsets = [] |
566 | 572 | if request.method == 'POST': |
567 | | form = ModelForm(request.POST, request.FILES, instance=obj) |
| 573 | if isinstance(ModelForm, ModelFormMetaclass): |
| 574 | form = ModelForm(request.POST, request.FILES, instance=obj) |
| 575 | else: |
| 576 | form = ModelForm |
568 | 577 | if form.is_valid(): |
569 | 578 | form_validated = True |
570 | 579 | new_object = self.save_form(request, form, change=True) |
… |
… |
|
586 | 595 | self.log_change(request, new_object, change_message) |
587 | 596 | return self.response_change(request, new_object) |
588 | 597 | else: |
589 | | form = ModelForm(instance=obj) |
| 598 | if isinstance(ModelForm, ModelFormMetaclass): |
| 599 | form = ModelForm(instance=obj) |
| 600 | else: |
| 601 | form = ModelForm |
590 | 602 | for FormSet in self.get_formsets(request, obj): |
591 | 603 | formset = FormSet(instance=obj) |
592 | 604 | formsets.append(formset) |