Skip to content

Commit

Permalink
Fix regression of form not being passed to `get_import_resource_kwa…
Browse files Browse the repository at this point in the history
…rgs()` (#1789)

* form param fix

* added test for form in kwargs
  • Loading branch information
matthewhegarty committed Apr 13, 2024
1 parent 452847a commit 0003034
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/changelog.rst
Expand Up @@ -5,6 +5,11 @@ Changelog

Version 4 introduces breaking changes. Please refer to :doc:`release notes<release_notes>`.

4.0.0-rc.3 (unreleased)
-----------------------

- fix form not being passed to ``get_import_resource_kwargs()`` (#1789)

4.0.0-rc.2 (2024-04-08)
-----------------------

Expand Down
2 changes: 1 addition & 1 deletion import_export/admin.py
Expand Up @@ -186,7 +186,7 @@ def process_dataset(
request,
**kwargs,
):
res_kwargs = self.get_import_resource_kwargs(request, **kwargs)
res_kwargs = self.get_import_resource_kwargs(request, form=form, **kwargs)
resource = self.choose_import_resource_class(form, request)(**res_kwargs)
imp_kwargs = self.get_import_data_kwargs(request=request, form=form, **kwargs)
imp_kwargs["retain_instance_in_row_result"] = True
Expand Down
3 changes: 3 additions & 0 deletions tests/core/admin.py
Expand Up @@ -82,6 +82,9 @@ def get_import_resource_kwargs(self, request, **kwargs):
# update resource kwargs so that the Resource is passed the authenticated user
# This is included as an example of how dynamic values
# can be passed to resources
if "form" not in kwargs:
# test for #1789
raise ValueError("'form' param was expected in kwargs")
kwargs = super().get_resource_kwargs(request, **kwargs)
kwargs.update({"user": request.user})
return kwargs
Expand Down

0 comments on commit 0003034

Please sign in to comment.