Extend functionality of `django-import-export`
Project description
Django-import-export-extensions
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_class = 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_import_export_extensions-1.0.1.tar.gz
.
File metadata
- Download URL: django_import_export_extensions-1.0.1.tar.gz
- Upload date:
- Size: 45.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2a6962230d1bf595973bf8242f5f896d1fa8dacf2360e58919bc196bbd45eb2 |
|
MD5 | 0e90d45971609842cc7f47b68556cf0c |
|
BLAKE2b-256 | 654af8ef417b26f6ab3ca9d07f6b0e4a34f2a5c006eb2107623cb6ff79c2480c |
File details
Details for the file django_import_export_extensions-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: django_import_export_extensions-1.0.1-py3-none-any.whl
- Upload date:
- Size: 67.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.7 Darwin/24.0.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e720d26ecd1219ecf1a7df7aa794a02fc63fb5606f55e37947b5028fc6964f0 |
|
MD5 | 84527b160a5b98e18eb97ae07a831a85 |
|
BLAKE2b-256 | 8d524eef5d4143201551ea548aa622f7e5853acd1c090bd349653eb893ae48a4 |