| 423 | def get_formset_instances(self, request, obj, change=True): |
| 424 | prefixes = {} |
| 425 | |
| 426 | inline_admin_formsets = [] |
| 427 | |
| 428 | for FormSet, inline in zip(self.get_formsets(request), self.inline_instances): |
| 429 | prefix = FormSet.get_default_prefix() |
| 430 | prefixes[prefix] = prefixes.get(prefix, 0) + 1 |
| 431 | if prefixes[prefix] != 1: |
| 432 | prefix = "%s-%s" % (prefix, prefixes[prefix]) |
| 433 | if request.method == 'POST': |
| 434 | formset = FormSet(data=request.POST, files=request.FILES, |
| 435 | instance=obj, |
| 436 | save_as_new=request.POST.has_key("_saveasnew"), |
| 437 | prefix=prefix, queryset=inline.queryset(request)) |
| 438 | else: |
| 439 | formset = FormSet(instance=obj, prefix=prefix, |
| 440 | queryset=inline.queryset(request)) |
| 441 | |
| 442 | fieldsets = list(inline.get_fieldsets(request)) |
| 443 | readonly = list(inline.get_readonly_fields(request)) |
| 444 | inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, |
| 445 | fieldsets, readonly, model_admin=self) |
| 446 | inline_admin_formsets.append(inline_admin_formset) |
| 447 | |
| 448 | return inline_admin_formsets |
| 449 | |
788 | | prefixes = {} |
789 | | for FormSet, inline in zip(self.get_formsets(request), self.inline_instances): |
790 | | prefix = FormSet.get_default_prefix() |
791 | | prefixes[prefix] = prefixes.get(prefix, 0) + 1 |
792 | | if prefixes[prefix] != 1: |
793 | | prefix = "%s-%s" % (prefix, prefixes[prefix]) |
794 | | formset = FormSet(data=request.POST, files=request.FILES, |
795 | | instance=new_object, |
796 | | save_as_new=request.POST.has_key("_saveasnew"), |
797 | | prefix=prefix, queryset=inline.queryset(request)) |
798 | | formsets.append(formset) |
| 816 | inline_admin_formsets = self.get_formset_instances(request, new_object, False) |
| 817 | formsets = map(lambda x: x.formset, inline_admin_formsets) |
| 818 | |
819 | | prefixes = {} |
820 | | for FormSet, inline in zip(self.get_formsets(request), |
821 | | self.inline_instances): |
822 | | prefix = FormSet.get_default_prefix() |
823 | | prefixes[prefix] = prefixes.get(prefix, 0) + 1 |
824 | | if prefixes[prefix] != 1: |
825 | | prefix = "%s-%s" % (prefix, prefixes[prefix]) |
826 | | formset = FormSet(instance=self.model(), prefix=prefix, |
827 | | queryset=inline.queryset(request)) |
828 | | formsets.append(formset) |
| 839 | inline_admin_formsets = self.get_formset_instances(request, self.model(), False) |
| 840 | formsets = map(lambda x: x.formset, inline_admin_formsets) |
835 | | inline_admin_formsets = [] |
836 | | for inline, formset in zip(self.inline_instances, formsets): |
837 | | fieldsets = list(inline.get_fieldsets(request)) |
838 | | readonly = list(inline.get_readonly_fields(request)) |
839 | | inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, |
840 | | fieldsets, readonly, model_admin=self) |
841 | | inline_admin_formsets.append(inline_admin_formset) |
| 847 | for inline_admin_formset in inline_admin_formsets: |
886 | | prefixes = {} |
887 | | for FormSet, inline in zip(self.get_formsets(request, new_object), |
888 | | self.inline_instances): |
889 | | prefix = FormSet.get_default_prefix() |
890 | | prefixes[prefix] = prefixes.get(prefix, 0) + 1 |
891 | | if prefixes[prefix] != 1: |
892 | | prefix = "%s-%s" % (prefix, prefixes[prefix]) |
893 | | formset = FormSet(request.POST, request.FILES, |
894 | | instance=new_object, prefix=prefix, |
895 | | queryset=inline.queryset(request)) |
896 | | |
897 | | formsets.append(formset) |
| 893 | inline_admin_formsets = self.get_formset_instances(request, new_object, True) |
| 894 | formsets = map(lambda x: x.formset, inline_admin_formsets) |
911 | | prefixes = {} |
912 | | for FormSet, inline in zip(self.get_formsets(request, obj), self.inline_instances): |
913 | | prefix = FormSet.get_default_prefix() |
914 | | prefixes[prefix] = prefixes.get(prefix, 0) + 1 |
915 | | if prefixes[prefix] != 1: |
916 | | prefix = "%s-%s" % (prefix, prefixes[prefix]) |
917 | | formset = FormSet(instance=obj, prefix=prefix, |
918 | | queryset=inline.queryset(request)) |
919 | | formsets.append(formset) |
| 908 | inline_admin_formsets = self.get_formset_instances(request, obj, True) |
| 909 | formsets = map(lambda x: x.formset, inline_admin_formsets) |
926 | | inline_admin_formsets = [] |
927 | | for inline, formset in zip(self.inline_instances, formsets): |
928 | | fieldsets = list(inline.get_fieldsets(request, obj)) |
929 | | readonly = list(inline.get_readonly_fields(request, obj)) |
930 | | inline_admin_formset = helpers.InlineAdminFormSet(inline, formset, |
931 | | fieldsets, readonly, model_admin=self) |
932 | | inline_admin_formsets.append(inline_admin_formset) |
| 916 | for inline_admin_formset in inline_admin_formsets: |