Skip to main content

Extend functionality of `django-import-export`

Project description

Django-import-export-extensions

PyPI - Python Versions PyPI - Django Versions PyPI

Build status on Github Test coverage Documentation Status

PyPI Downloads

Links

Description

django-import-export-extensions extends the functionality of django-import-export adding the following features:

  • Import/export resources in the background via Celery
  • Manage import/export jobs via Django Admin
  • DRF integration that allows to work with import/export jobs via API
  • Support drf-spectacular generated API schema
  • Additional fields and widgets (FileWidget, IntermediateManyToManyWidget, IntermediateManyToManyField)

Installation

To install django-import-export-extensions, run this command in your terminal:

pip install django-import-export-extensions

Add import_export and import_export_extensions to INSTALLED_APPS

# settings.py
INSTALLED_APPS = (
    ...,
    "import_export",
    "import_export_extensions",
)

Run migrate command to create ImportJob/ExportJob models and collectstatic to let Django collect package static files to use in the admin.

python manage.py migrate
python manage.py collectstatic

Usage

Prepare resource for your model

# apps/books/resources.py
from import_export_extensions.resources import CeleryModelResource

from .. import models


class BookResource(CeleryModelResource):

    class Meta:
        model = models.Book

Use CeleryImportExportMixin class and set resource_classes in admin model to import/export via Django Admin

# apps/books/admin.py
from django.contrib import admin

from import_export_extensions.admin import CeleryImportExportMixin

from .. import resources


@admin.register(models.Book)
class BookAdmin(CeleryImportExportMixin, admin.ModelAdmin):
    resource_classes = [resources.BookResource]

Prepare view sets to import/export via API

# apps/books/api/views.py
from .. import resources

from import_export_extensions.api import views


class BookExportViewSet(views.ExportJobViewSet):
    resource_class = resources.BookResource


class BookImportViewSet(views.ImportJobViewSet):
    resource_class = resources.BookResource

Don't forget to configure Celery if you want to run import/export in background

License

  • Free software: MIT license

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_import_export_extensions-1.9.2.tar.gz (48.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file django_import_export_extensions-1.9.2.tar.gz.

File metadata

File hashes

Hashes for django_import_export_extensions-1.9.2.tar.gz
Algorithm Hash digest
SHA256 6d3d89f235c2e3552d1348c285e9426375db9ff24b90d8153b94165d2f233f51
MD5 443861ccd4eb317f27953e2191c01733
BLAKE2b-256 f74ae0dfd1d032df85e0fc794cdf19471e94b6264c586c715a6928ff191fe900

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_import_export_extensions-1.9.2.tar.gz:

Publisher: publish.yml on saritasa-nest/django-import-export-extensions

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_import_export_extensions-1.9.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_import_export_extensions-1.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 800ad38df2a22bd3d21f9f19a9c5ac2d1cd647f64776e5b0287212c89301495e
MD5 00a9db41fa8ad6edec72bfd2ff430a9a
BLAKE2b-256 579c38e34e1353259614b8f281f6d2bedfb21010e37074c64437abde25bc42bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_import_export_extensions-1.9.2-py3-none-any.whl:

Publisher: publish.yml on saritasa-nest/django-import-export-extensions

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page