Skip to content

Commit

Permalink
Merge pull request django-import-export#406 from django-import-export…
Browse files Browse the repository at this point in the history
…/action_formats_js

show formats selector only when export action is selected
  • Loading branch information
bmihelac committed Feb 19, 2016
2 parents be0ad0d + 90a5a82 commit db52ac2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
16 changes: 13 additions & 3 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Configuration
=============

The only mandatory configuration is adding ``import_export`` to your
``INSTALLED_APPS``. This isn't necessary, if admin integration is not
used.
You only need to perform this configuration step if you use django-import-export in the admin.

Add ``import_export`` to your ``INSTALLED_APPS``:

INSTALLED_APPS = [
# ...

'import_export',
]

Deploy static files:

$ python manage.py collectstatic
3 changes: 3 additions & 0 deletions import_export/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,9 @@ def export_admin_action(self, request, queryset):

actions = [export_admin_action]

class Media:
js = ['import_export/action_formats.js']


class ImportExportActionModelAdmin(ImportMixin, ExportActionModelAdmin):
"""
Expand Down
12 changes: 12 additions & 0 deletions import_export/static/import_export/action_formats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(function($) {
$(document).on('ready', function() {
$('select[name="action"]', '#changelist-form').on('change', function() {
if ($(this).val() == 'export_admin_action') {
$('select[name="file_format"]', '#changelist-form').parent().show();
} else {
$('select[name="file_format"]', '#changelist-form').parent().hide();
}
});
$('select[name="action"]', '#changelist-form').change();
});
})(django.jQuery);

0 comments on commit db52ac2

Please sign in to comment.