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

Issue:
[3.0] Beta3 breaks on import page
Beta 2 works ok. Updating to beta 3 produces error when loading import page:

`__init__()` got multiple values for argument 'data'

I cannot find the commit or tag for beta 2.


Discussion:
The problem is in this commit: https://github.com/django-import-export/django-import-export/commit/cd0ab61955998ab27840d2ee2b6898d9d892a695
Can you reproduce in the example app?
Hi Matthew, didn't try. I'm debugging the changes on the commit to see where the problem is. Will get to it if I fail to find original problem.

Resolving patch:
diff --git a/import_export/admin.py b/import_export/admin.py
--- a/import_export/admin.py
+++ b/import_export/admin.py
@@ -17,7 +17,13 @@
 from django.views.decorators.http import require_POST
 
 from .formats.base_formats import DEFAULT_FORMATS
-from .forms import ConfirmImportForm, ExportForm, ImportForm, export_action_form_factory
+from .forms import (
+    ConfirmImportForm,
+    ExportForm,
+    ImportExportFormBase,
+    ImportForm,
+    export_action_form_factory,
+)
 from .mixins import BaseExportMixin, BaseImportMixin
 from .results import RowResult
 from .signals import post_export, post_import
@@ -252,6 +258,14 @@ def create_import_form(self, request):
         formats = self.get_import_formats()
         form_class = self.get_import_form_class(request)
         kwargs = self.get_import_form_kwargs(request)
+
+        if not issubclass(form_class, ImportExportFormBase):
+            warnings.warn(
+                "The ImportForm class must inherit from ImportExportFormBase, "
+                "this is needed for multiple resource classes to work properly. ",
+                category=DeprecationWarning
+            )
+            return form_class(formats, **kwargs)
         return form_class(formats, self.get_import_resource_classes(), **kwargs)
 
     def get_import_form_class(self, request):
@@ -423,13 +437,27 @@ def import_action(self, request, *args, **kwargs):
         else:
             form_class = self.get_import_form_class(request)
             form_kwargs = self.get_form_kwargs(form_class, *args, **kwargs)
-            import_form = form_class(
-                import_formats,
-                self.get_import_resource_classes(),
-                request.POST or None,
-                request.FILES or None,
-                **form_kwargs
-            )
+
+            if issubclass(form_class, ImportExportFormBase):
+                import_form = form_class(
+                    import_formats,
+                    self.get_import_resource_classes(),
+                    request.POST or None,
+                    request.FILES or None,
+                    **form_kwargs
+                )
+            else:
+                warnings.warn(
+                    "The ImportForm class must inherit from ImportExportFormBase, "
+                    "this is needed for multiple resource classes to work properly. ",
+                    category=DeprecationWarning
+                )
+                import_form = form_class(
+                    import_formats,
+                    request.POST or None,
+                    request.FILES or None,
+                    **form_kwargs
+                )
 
         resources = list()
         if request.POST and import_form.is_valid():


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
@@ -641,6 +641,46 @@ def test_import_with_customized_forms(self):
                 1, 0, EBook._meta.verbose_name_plural)
         )
 
+    @mock.patch('core.admin.BookAdmin.get_import_form_class')
+    def test_deprecated_importform_new_api_raises_warning(self, mock_get_import_form):
+        class DjangoImportForm(django.forms.Form):
+            def __init__(self, import_formats, *args, **kwargs):
+                super().__init__(*args, **kwargs)
+
+        mock_get_import_form.return_value = DjangoImportForm
+
+        with self.assertWarnsRegex(
+                DeprecationWarning,
+                r"^The ImportForm class must inherit from ImportExportFormBase, "
+                r"this is needed for multiple resource classes to work properly. $"
+                ):
+            # GET the import form
+            response = self.client.get('/admin/core/book/import/')
+            self.assertEqual(response.status_code, 200)
+            self.assertTemplateUsed(response, 'admin/import_export/import.html')
+            self.assertContains(response, 'form action=""')
+
+    @mock.patch('core.admin.BookAdmin.get_import_form_class')
+    @mock.patch('core.admin.BookAdmin.get_form_kwargs')
+    def test_deprecated_importform_raises_warning(self, mock_get_form_kwargs, mock_get_import_form):
+        class DjangoImportForm(django.forms.Form):
+            def __init__(self, import_formats, *args, **kwargs):
+                super().__init__(*args, **kwargs)
+
+        mock_get_form_kwargs.is_original = False
+        mock_get_import_form.return_value = DjangoImportForm
+
+        with self.assertWarnsRegex(
+                DeprecationWarning,
+                r"^The ImportForm class must inherit from ImportExportFormBase, "
+                r"this is needed for multiple resource classes to work properly. $"
+                ):
+            # GET the import form
+            response = self.client.get('/admin/core/book/import/')
+            self.assertEqual(response.status_code, 200)
+            self.assertTemplateUsed(response, 'admin/import_export/import.html')
+            self.assertContains(response, 'form action=""')
+
     def test_get_skip_admin_log_attribute(self):
         m = ImportMixin()
         m.skip_admin_log = True
@@ -946,7 +986,7 @@ def __init__(self):
 
         m = TestCategoryAdmin()
         action_form = m.action_form
- 
+
         items = list(action_form.base_fields.items())
         file_format = items[len(items)-1][1]
         choices = file_format.choices
@@ -971,7 +1011,7 @@ def __init__(self):
 
         m = TestCategoryAdmin()
         action_form = m.action_form
- 
+
         items = list(action_form.base_fields.items())
         file_format = items[len(items)-1][1]
         choices = file_format.choices
@@ -981,7 +1021,7 @@ def __init__(self):
 
         m = TestFormatsCategoryAdmin()
         action_form = m.action_form
- 
+
         items = list(action_form.base_fields.items())
         file_format = items[len(items)-1][1]
         choices = file_format.choices