Repository: django-import-export/django-import-export

Issue:
`get_resource_kwargs` should return kwargs passed
**Describe the bug**

```
    def get_resource_kwargs(self, request, *args, **kwargs):
        return {}
```

This block will remove any values currently present in `kwargs`, which means data is lost and it is not easy to override.
[source](https://github.com/django-import-export/django-import-export/blob/eabba74bbfe0128411612c064b8e65900ab377ee/import_export/mixins.py#L65)

The correct implementation should be:

```
    def get_resource_kwargs(self, request, *args, **kwargs):
        return kwargs
```

There should be tests to prove this fix

**Versions (please complete the following information):**
 - Django Import Export: 3.3.6





Discussion:
@matthewhegarty Modify the return value of get_resource_kwargs and write a test for it? If that's what you want, I'll get on that asap.

Hi Rob - yes that is all that is needed (along with changelog update).  I would suggest this fix goes into the `main` branch and then we can port to `release-4`.
in case it matters I am sitting down to tackle this at this very moment, if you needed to assign anyone for records or anything along those lines.
@matthewhegarty 

Thanks - feel free to assign it to yourself :+1:

Resolving patch:
diff --git a/import_export/mixins.py b/import_export/mixins.py
--- a/import_export/mixins.py
+++ b/import_export/mixins.py
@@ -15,6 +15,11 @@
 
 
 class BaseImportExportMixin:
+    """
+    Base mixin for functionality related to importing and exporting via the Admin
+    interface.
+    """
+
     resource_class = None
     resource_classes = []
 
@@ -63,9 +68,24 @@ def get_resource_classes(self):
         return [self.resource_class]
 
     def get_resource_kwargs(self, request, *args, **kwargs):
+        """
+        Return the kwargs which are to be passed to the Resource constructor.
+        Can be overridden to provide additional kwarg params.
+
+        :param request: The request object.
+        :param args: Positional arguments.
+        :param kwargs: Keyword arguments.
+        :returns: The Resource kwargs (by default, is the kwargs passed).
+        """
         return kwargs
 
     def get_resource_index(self, form):
+        """
+        Return the index of the resource class defined in the form.
+
+        :param form: The form object.
+        :returns: The index of the resource as an int.
+        """
         resource_index = 0
         if form and "resource" in form.cleaned_data:
             try:


Test patch:
diff --git a/tests/core/tests/test_admin_integration.py b/tests/core/tests/test_admin_integration.py
--- a/tests/core/tests/test_admin_integration.py
+++ b/tests/core/tests/test_admin_integration.py
@@ -123,22 +123,6 @@ def test_import_export_template(self):
         self.assertContains(response, _("Export"))
         self.assertContains(response, "Custom change list item")
 
-    @patch("import_export.admin.ImportMixin.choose_import_resource_class")
-    def test_import_passes_correct_kwargs_to_constructor(
-        self, mock_choose_import_resource_class
-    ):
-        class TestResource(ModelResource):
-            def __init__(self, **kwargs):
-                super().__init__(**kwargs)
-                self.kwargs = kwargs
-                if "form" not in kwargs:
-                    raise Exception("No form")
-
-        mock_choose_import_resource_class.return_value = TestResource
-
-        response = self._do_import_post(self.book_import_url, "books.csv")
-        self.assertEqual(response.status_code, 200)
-
     @override_settings(TEMPLATE_STRING_IF_INVALID="INVALID_VARIABLE")
     def test_import(self):
         # GET the import form
@@ -191,6 +175,26 @@ def test_correct_scripts_declared_when_debug_is_true(self):
             html=True,
         )
 
+    @patch("import_export.admin.ImportMixin.choose_import_resource_class")
+    def test_import_passes_correct_kwargs_to_constructor(
+        self, mock_choose_import_resource_class
+    ):
+        # issue 1741
+        class TestResource(ModelResource):
+            def __init__(self, **kwargs):
+                super().__init__(**kwargs)
+
+                # the form is passed as a kwarg to the Resource constructor
+                # if not present, then it means that the original kwargs were lost
+                if "form" not in kwargs:
+                    raise Exception("No form")
+
+        # mock the returned resource class so that we can inspect constructor params
+        mock_choose_import_resource_class.return_value = TestResource
+
+        response = self._do_import_post(self.book_import_url, "books.csv")
+        self.assertEqual(response.status_code, 200)
+
     @override_settings(DEBUG=False)
     def test_correct_scripts_declared_when_debug_is_false(self):
         # GET the import form