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

Issue:
Format field is always shown on Django 2.2
After upgrading to Django 2.2, the `Format` field is always shown in admins where I inherit from `ImportExportActionModelAdmin`, even thougt the export action is not selected. Here is a screenshot:
![Skærmbillede fra 2019-10-02 16-05-52](https://user-images.githubusercontent.com/724716/66051066-9904dd80-e52e-11e9-94e4-128178bb9aa3.png)

Format field is always shown on Django 2.2
After upgrading to Django 2.2, the `Format` field is always shown in admins where I inherit from `ImportExportActionModelAdmin`, even thougt the export action is not selected. Here is a screenshot:
![Skærmbillede fra 2019-10-02 16-05-52](https://user-images.githubusercontent.com/724716/66051066-9904dd80-e52e-11e9-94e4-128178bb9aa3.png)



Discussion:
I get the following error in the JS console:
```
Uncaught TypeError: $ is not a function
    at action_formats.js:2
    at action_formats.js:22
```
after some debugging it seems that the issue is that `action_formats.js` is run before `jQuery.init.js`.
Inspecting the HTML reveals that the scripts are loaded in this order:
```html
<script type="text/javascript" src="/static/admin/js/vendor/jquery/jquery.js"></script>
<script type="text/javascript" src="/static/import_export/action_formats.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
<script type="text/javascript" src="/static/admin/js/core.js"></script>
<script type="text/javascript" src="/static/admin/js/admin/RelatedObjectLookups.js"></script>
<script type="text/javascript" src="/static/admin/js/actions.js"></script>
<script type="text/javascript" src="/static/admin/js/urlify.js"></script>
<script type="text/javascript" src="/static/admin/js/prepopulate.js"></script>
<script type="text/javascript" src="/static/admin/js/vendor/xregexp/xregexp.js"></script>
```

I can fix this order by changing `import_export/admin.py` the following way:
```python
class ExportActionMixin(ExportMixin):
    ...
    class Media:
        js = ['import_export/action_formats.js']
```
to
```python
from django import forms
...
class ExportActionMixin(ExportMixin):
    ...
    @property
    def media(self):
        super_media = super().media
        return forms.Media(js=super_media._js + ['import_export/action_formats.js'], css=super_media._js)
```
But even though the JS error is gone, the contents of `$(document).on('ready', function() {` in `import_export/static/import_export/action_formats.js` is never run.
Changing `$(document).on('ready', function() {` to `$(document).ready(function() {` however fixes the problem.

This is because, as per [the official documentation](https://api.jquery.com/ready/) and [this ticket](https://bugs.jquery.com/ticket/11719), `$(document).on("ready", fn);` has been deprecated since v1.8 of jQuery, and it is completely gone in Django 2.2, which uses jQuery 3.3 for the admin.

I would like to make a pull request for these changes, but first I would like to know whether 2.0 is coming soon, or I should make changes to the 1.x branch as well, to get a v 1.2.1 out quickly? 
I get the following error in the JS console:
```
Uncaught TypeError: $ is not a function
    at action_formats.js:2
    at action_formats.js:22
```
after some debugging it seems that the issue is that `action_formats.js` is run before `jQuery.init.js`.
Inspecting the HTML reveals that the scripts are loaded in this order:
```html
<script type="text/javascript" src="/static/admin/js/vendor/jquery/jquery.js"></script>
<script type="text/javascript" src="/static/import_export/action_formats.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.init.js"></script>
<script type="text/javascript" src="/static/admin/js/core.js"></script>
<script type="text/javascript" src="/static/admin/js/admin/RelatedObjectLookups.js"></script>
<script type="text/javascript" src="/static/admin/js/actions.js"></script>
<script type="text/javascript" src="/static/admin/js/urlify.js"></script>
<script type="text/javascript" src="/static/admin/js/prepopulate.js"></script>
<script type="text/javascript" src="/static/admin/js/vendor/xregexp/xregexp.js"></script>
```

I can fix this order by changing `import_export/admin.py` the following way:
```python
class ExportActionMixin(ExportMixin):
    ...
    class Media:
        js = ['import_export/action_formats.js']
```
to
```python
from django import forms
...
class ExportActionMixin(ExportMixin):
    ...
    @property
    def media(self):
        super_media = super().media
        return forms.Media(js=super_media._js + ['import_export/action_formats.js'], css=super_media._js)
```
But even though the JS error is gone, the contents of `$(document).on('ready', function() {` in `import_export/static/import_export/action_formats.js` is never run.
Changing `$(document).on('ready', function() {` to `$(document).ready(function() {` however fixes the problem.

This is because, as per [the official documentation](https://api.jquery.com/ready/) and [this ticket](https://bugs.jquery.com/ticket/11719), `$(document).on("ready", fn);` has been deprecated since v1.8 of jQuery, and it is completely gone in Django 2.2, which uses jQuery 3.3 for the admin.

I would like to make a pull request for these changes, but first I would like to know whether 2.0 is coming soon, or I should make changes to the 1.x branch as well, to get a v 1.2.1 out quickly? 

Resolving patch:
diff --git a/import_export/admin.py b/import_export/admin.py
--- a/import_export/admin.py
+++ b/import_export/admin.py
@@ -3,6 +3,7 @@
 from datetime import datetime
 
 import django
+from django import forms
 from django.contrib import admin
 from django.contrib.auth import get_permission_codename
 from django.utils import six
@@ -526,8 +527,10 @@ def export_admin_action(self, request, queryset):
 
     actions = [export_admin_action]
 
-    class Media:
-        js = ['import_export/action_formats.js']
+    @property
+    def media(self):
+        super_media = super().media
+        return forms.Media(js=super_media._js + ['import_export/action_formats.js'], css=super_media._css)
 
 
 class ExportActionModelAdmin(ExportActionMixin, admin.ModelAdmin):
diff --git a/import_export/resources.py b/import_export/resources.py
--- a/import_export/resources.py
+++ b/import_export/resources.py
@@ -9,11 +9,12 @@
 
 from diff_match_patch import diff_match_patch
 
+import django
 from django.conf import settings
 from django.core.exceptions import ImproperlyConfigured, ValidationError
 from django.core.management.color import no_style
 from django.db import connections, DEFAULT_DB_ALIAS
-from django.db.models.fields import FieldDoesNotExist
+from django.db.models.fields.related import ForeignObjectRel
 from django.db.models.query import QuerySet
 from django.db.transaction import TransactionManagementError, atomic, savepoint, savepoint_rollback, savepoint_commit
 from django.utils import six
@@ -26,7 +27,10 @@
 from .results import Error, Result, RowResult
 from .utils import atomic_if_using_transaction
 
-from django.db.models.fields.related import ForeignObjectRel
+if django.VERSION[0] >= 3:
+    from django.core.exceptions import FieldDoesNotExist
+else:
+    from django.db.models.fields import FieldDoesNotExist
 
 
 logger = logging.getLogger(__name__)


Test patch:
diff --git a/tests/core/tests/test_resources.py b/tests/core/tests/test_resources.py
--- a/tests/core/tests/test_resources.py
+++ b/tests/core/tests/test_resources.py
@@ -8,11 +8,11 @@
 from decimal import Decimal
 from unittest import skip, skipUnless
 
+import django
 from django.conf import settings
 from django.contrib.auth.models import User
 from django.db import IntegrityError, DatabaseError
 from django.db.models import Count
-from django.db.models.fields import FieldDoesNotExist
 from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
 from django.utils import six
 from django.utils.html import strip_tags
@@ -27,6 +27,12 @@
     WithFloatField, Person, Role
 )
 
+if django.VERSION[0] >= 3:
+    from django.core.exceptions import FieldDoesNotExist
+else:
+    from django.db.models.fields import FieldDoesNotExist
+
+
 
 class MyResource(resources.Resource):
     name = fields.Field()