diff --git a/nested_inline/admin.py b/nested_inline/admin.py index 6793771..45018f9 100644 --- a/nested_inline/admin.py +++ b/nested_inline/admin.py @@ -165,7 +165,7 @@ def add_view(self, request, form_url='', extra_context=None): form_validated = False new_object = self.model() prefixes = {} - for FormSet, inline in zip(self.get_formsets(request), inline_instances): + for FormSet, inline in self.get_formsets_with_inlines(request): prefix = FormSet.get_default_prefix() prefixes[prefix] = prefixes.get(prefix, 0) + 1 if prefixes[prefix] != 1 or not prefix: @@ -180,7 +180,7 @@ def add_view(self, request, form_url='', extra_context=None): if self.all_valid_with_nesting(formsets) and form_validated: self.save_model(request, new_object, form, False) self.save_related(request, form, formsets, False) - self.log_addition(request, new_object) + self.log_addition(request, new_object, '') return self.response_add(request, new_object) else: # Prepare the dict of initial data from the request. @@ -195,7 +195,7 @@ def add_view(self, request, form_url='', extra_context=None): initial[k] = initial[k].split(",") form = ModelForm(initial=initial) prefixes = {} - for FormSet, inline in zip(self.get_formsets(request), inline_instances): + for FormSet, inline in self.get_formsets_with_inlines(request): prefix = FormSet.get_default_prefix() prefixes[prefix] = prefixes.get(prefix, 0) + 1 if prefixes[prefix] != 1 or not prefix: @@ -227,7 +227,7 @@ def add_view(self, request, form_url='', extra_context=None): context = { 'title': _('Add %s') % force_text(opts.verbose_name), 'adminform': adminForm, - 'is_popup': "_popup" in request.REQUEST, + 'is_popup': "_popup" in request.get_full_path(), 'show_delete': False, 'media': media, 'inline_admin_formsets': inline_admin_formsets, @@ -269,7 +269,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None): form_validated = False new_object = obj prefixes = {} - for FormSet, inline in zip(self.get_formsets(request, new_object), inline_instances): + for FormSet, inline in self.get_formsets_with_inlines(request, new_object): prefix = FormSet.get_default_prefix() prefixes[prefix] = prefixes.get(prefix, 0) + 1 if prefixes[prefix] != 1 or not prefix: @@ -291,7 +291,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None): else: form = ModelForm(instance=obj) prefixes = {} - for FormSet, inline in zip(self.get_formsets(request, obj), inline_instances): + for FormSet, inline in self.get_formsets_with_inlines(request, obj): prefix = FormSet.get_default_prefix() prefixes[prefix] = prefixes.get(prefix, 0) + 1 if prefixes[prefix] != 1 or not prefix: @@ -325,7 +325,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None): 'adminform': adminForm, 'object_id': object_id, 'original': obj, - 'is_popup': "_popup" in request.REQUEST, + 'is_popup': "_popup" in request.get_full_path(), 'media': media, 'inline_admin_formsets': inline_admin_formsets, 'errors': helpers.AdminErrorList(form, formsets),