Skip to main content

Extend functionality of `django-import-export`

Project description

django-import-export-extensions

GitHub last commit GitHub Workflow Status (with event) PyPI PyPI - Status PyPI - Python Version PyPI - Django Versions PyPI - License PyPI - Downloads Ruff

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.10.1.tar.gz (710.0 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.10.1.tar.gz.

File metadata

  • Download URL: django_import_export_extensions-1.10.1.tar.gz
  • Upload date:
  • Size: 710.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_import_export_extensions-1.10.1.tar.gz
Algorithm Hash digest
SHA256 a6af40e053fd1f96517eebc8c79dec22380f52d22c8e9b04580165bee6997aa9
MD5 affc975b1186fcc194afcd17296c00a0
BLAKE2b-256 1cf11adddd255ab57e230eee76c65f9305e63d40379ad388c36abb30542fcc6b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_import_export_extensions-1.10.1-py3-none-any.whl
  • Upload date:
  • Size: 77.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for django_import_export_extensions-1.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce231ec965374ce80768dbd0dc2cf3affe63adfb32a975d8f6fa37da6b21ad25
MD5 0639ca7ecf833ab9457f77c20d26892e
BLAKE2b-256 5c31d54b92a46175f021d093a3f49f925629e4d6846b4c07a41b7c746e73b744

See more details on using hashes here.

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