diff --git a/README.rst b/README.rst
index b5be367..5929040 100644
--- a/README.rst
+++ b/README.rst
@@ -169,6 +169,14 @@ To exclude or disable file formats from the admin site, configure `IMPORT_EXPORT
IMPORT_EXPORT_CELERY_EXCLUDED_FORMATS = ["csv", "xls"]
+Customizing File Storage Backend
+--------------------------------
+
+Define a custom storage backend by adding the `IMPORT_EXPORT_CELERY_STORAGE` to your Django settings. For instance:
+
+ ::
+
+ IMPORT_EXPORT_CELERY_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
Customizing email template for export job completion email
----------------------------------------------------------
@@ -215,10 +223,10 @@ Before submitting a PR please run `flake8` and (in the examples directory) `pyth
Please note, that you need to restart celery for changes to propogate to the workers. Do this with `docker-compose down celery`, `docker-compose up celery`.
-Comercial support
+Commercial support
-----------------
-Comercial support is provided by `gradesta s.r.o `_.
+Commercial support is provided by `gradesta s.r.o `_.
Credits
-------
diff --git a/example/project/settings.py b/example/project/settings.py
index 58b6c6a..f5fce3f 100644
--- a/example/project/settings.py
+++ b/example/project/settings.py
@@ -135,3 +135,4 @@
}
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
+IMPORT_EXPORT_CELERY_STORAGE = "django.core.files.storage.FileSystemStorage"
diff --git a/import_export_celery/fields.py b/import_export_celery/fields.py
new file mode 100644
index 0000000..53ad05e
--- /dev/null
+++ b/import_export_celery/fields.py
@@ -0,0 +1,13 @@
+from django.conf import settings
+from django.core.files.storage import get_storage_class
+from django.db import models
+
+
+class ImportExportFileField(models.FileField):
+ def __init__(self, *args, **kwargs):
+ # If the user has specified a custom storage backend, use it.
+ if settings.IMPORT_EXPORT_CELERY_STORAGE:
+ storage_class = get_storage_class(settings.IMPORT_EXPORT_CELERY_STORAGE)
+ kwargs["storage"] = storage_class()
+
+ super().__init__(*args, **kwargs)
diff --git a/import_export_celery/models/exportjob.py b/import_export_celery/models/exportjob.py
index 3eb01b3..66f5691 100644
--- a/import_export_celery/models/exportjob.py
+++ b/import_export_celery/models/exportjob.py
@@ -12,6 +12,7 @@
from django.db.models.signals import post_save
from django.utils.translation import gettext_lazy as _
+from ..fields import ImportExportFileField
from ..tasks import run_export_job
from ..utils import get_formats
@@ -22,7 +23,7 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._content_type = None
- file = models.FileField(
+ file = ImportExportFileField(
verbose_name=_("exported file"),
upload_to="django-import-export-celery-export-jobs",
blank=False,
diff --git a/import_export_celery/models/importjob.py b/import_export_celery/models/importjob.py
index a9bef5b..c6d3a6d 100644
--- a/import_export_celery/models/importjob.py
+++ b/import_export_celery/models/importjob.py
@@ -13,12 +13,13 @@
from import_export.formats.base_formats import DEFAULT_FORMATS
+from ..fields import ImportExportFileField
from ..tasks import run_import_job
@with_author
class ImportJob(models.Model):
- file = models.FileField(
+ file = ImportExportFileField(
verbose_name=_("File to be imported"),
upload_to="django-import-export-celery-import-jobs",
blank=False,
@@ -45,7 +46,7 @@ class ImportJob(models.Model):
max_length=255,
)
- change_summary = models.FileField(
+ change_summary = ImportExportFileField(
verbose_name=_("Summary of changes made by this import"),
upload_to="django-import-export-celery-import-change-summaries",
blank=True,