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

Issue:
Error when trying to open export windows with import_export 3.3.4
**Describe the bug**
Error when trying to open export windows with import_export 3.3.4

**To Reproduce**
Steps to reproduce the behavior:
1. Go to 'admin model section'
2. Click on 'export'
4. See error

**Versions (please complete the following information):**
 - Django Import Export: 3.3.4
 - Python 3.8.12
 - Django 3.2.14

**Expected behavior**
N/A

**Screenshots**
N/A

**Additional context**

**Error message:**

```
TypeError __init__() got an unexpected keyword argument 'model'
Traceback (most recent call last):
  File "/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/venv/lib/python3.8/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/venv/lib/python3.8/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/venv/lib/python3.8/site-packages/django/contrib/admin/sites.py", line 232, in inner
    return view(request, *args, **kwargs)
  File "/venv/lib/python3.8/site-packages/import_export/admin.py", line 836, in export_action
    context["fields_list"] = [
  File "/venv/lib/python3.8/site-packages/import_export/admin.py", line 841, in <listcomp>
    for field in res(model=self.model).get_user_visible_fields()
TypeError: __init__() got an unexpected keyword argument 'model'
```

I see that this problem is introduction in this PR https://github.com/django-import-export/django-import-export/pull/1685/files
Maybe, this is related to the older version of Django, I see that the code for the construction fields in `import_action` and `export_actions` are different and I'm not sure if it's okay or if it's better to normal.

Version 3.3.2 works fine.


Discussion:
I couldn't reproduce this using the import-export example app.  

- Can you reproduce with the [example app](https://django-import-export.readthedocs.io/en/latest/installation.html#example-app)?  
- Does it still occur if you upgrade to Django 4.2? (3.2 is unsupported from [April](https://endoflife.date/django)).
- Can you give us more information on how to reproduce?  (can you post an example Resource definition)
I experienced this error after upgrading from 3.3.3 to 3.3.6

Django: 4.2.9
Python: 3.10.3
This is the Resource that's causing the problem. It's a base class from which other resources inherit.

```
class PIIModelResource(resources.ModelResource):
    def __init__(self, user):
        self.user = user

    def export(self, queryset=None, *args, **kwargs):
        if self.user.has_perm("core.view_person"):
            return super().export(queryset, *args, **kwargs)
        else:
            raise ValidationError("You do not have permission to export this information")
```
Thanks for posting, I'll look in depth later but I wonder if the overridden constructor is the issue.  I wonder if it would work if you changed the constructor to:

```python
  def __init__(user, model=None)
    super().__init__(model=model)
    self.user = user
```
This fixed it, thanks!

```python
    def __init__(self, user=None, model=None):
        super().__init__(model=model)
        self.user = user
```

Resolving patch:
diff --git a/import_export/admin.py b/import_export/admin.py
--- a/import_export/admin.py
+++ b/import_export/admin.py
@@ -856,7 +856,7 @@ def export_action(self, request, *args, **kwargs):
                 [
                     field.column_name
                     for field in res(
-                        model=self.model, **self.get_export_resource_kwargs(request)
+                        **self.get_export_resource_kwargs(request)
                     ).get_user_visible_fields()
                 ],
             )


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
@@ -8,7 +8,13 @@
 import chardet
 import django
 import tablib
-from core.admin import AuthorAdmin, BookAdmin, CustomBookAdmin, ImportMixin
+from core.admin import (
+    AuthorAdmin,
+    BookAdmin,
+    BookResource,
+    CustomBookAdmin,
+    ImportMixin,
+)
 from core.models import Author, Book, Category, EBook, Parent
 from django.contrib.admin.models import DELETION, LogEntry
 from django.contrib.admin.sites import AdminSite
@@ -685,6 +691,18 @@ def test_export_passes_export_resource_kwargs(
         self.assertEqual(response.status_code, 200)
         self.assertEqual(2, mock_get_export_resource_kwargs.call_count)
 
+    def book_resource_init(self):
+        # stub call to the resource constructor
+        pass
+
+    @mock.patch.object(BookResource, "__init__", book_resource_init)
+    def test_export_passes_no_resource_constructor_params(self):
+        # issue 1716
+        # assert that the export call with a no-arg constructor
+        # does not crash
+        response = self.client.get("/admin/core/book/export/")
+        self.assertEqual(response.status_code, 200)
+
     def test_export(self):
         response = self.client.get("/admin/core/book/export/")
         self.assertEqual(response.status_code, 200)