Admin
- class import_export_extensions.admin.model_admins.export_job_admin.ExportJobAdmin(model, admin_site)
Admin class for debugging ExportJob.
- cancel_jobs(request: WSGIRequest, queryset: QuerySet)
Admin action for cancelling data export.
- export_data_action(request: WSGIRequest, obj: ExportJob)
Admin action for starting data export.
Data export should auto start after export confirmation. But there may be issues with celery and task did not start. So this action for such cases.
- export_job_progress_view(request: WSGIRequest, job_id: int, **kwargs)
View to return ExportJob status as JSON.
If current status is exporting, view also returns job state and percent of completed work.
- Return:
Response: dictionary with status (optionally, state and percent).
- form
alias of
ExportJobAdminForm
- get_fieldsets(request: WSGIRequest, obj: ExportJob | None = None)
Get fieldsets depending on object status.
- get_readonly_fields(request, obj=None)
Return readonly fields.
Some fields are editable for new ExportJob.
- get_urls()
Add url to get current export job progress in JSON representation.
/admin/import_export_extensions/exportjob/<job_id>/progress/
- class import_export_extensions.admin.model_admins.import_job_admin.ImportJobAdmin(model, admin_site)
Admin class for debugging ImportJob.
- cancel_jobs(request: WSGIRequest, queryset: QuerySet)
Admin action for cancelling data import.
- confirm_jobs(request: WSGIRequest, queryset: QuerySet)
Admin action for confirming data import.
- form
alias of
ImportJobAdminForm
- get_fieldsets(request: WSGIRequest, obj: ImportJob | None = None)
Get fieldsets depending on object status.
- get_queryset(request: WSGIRequest)
Override get_queryset.
Do not get result from db because it can be rather big and is not used in admin.
- get_readonly_fields(request: WSGIRequest, obj: ImportJob | None = None) list[str]
Return readonly fields.
Some fields are editable for new ImportJob.
- get_urls()
Add url to get current import job progress in JSON representation.
/admin/import_export_extensions/importjob/<job_id>/progress/
- import_job_progress_view(request: WSGIRequest, job_id: int, **kwargs) JsonResponse
View to return
ImportJob
status as JSON.If current status is parsing/importing, view also returns job state and percent of completed work.
- Return:
Response: dictionary with status (optionally, state and percent).
- class import_export_extensions.admin.model_admins.mixins.BaseImportExportJobAdminMixin
Mixin provides common methods for ImportJob and ExportJob admins.
- get_from_content_type(obj: ImportJob | ExportJob) ContentType | None
Shortcut to get object from content_type.
- has_add_permission(request: WSGIRequest, *args, **kwargs) bool
Import/Export Jobs should not be created using this interface.
- has_delete_permission(request: WSGIRequest, *args, **kwargs) bool
Import/Export Jobs should not be deleted using this interface.
Instead, admins must cancel jobs.
- class import_export_extensions.admin.forms.export_job_admin_form.ExportJobAdminForm(instance: ExportJob, *args, **kwargs)
Admin form for ExportJob model.
Adds custom export_progressbar field that displays current export progress using AJAX requests to specified endpoint. Fields widget is defined in __init__ method.
- property media
Return all media required to render the widgets on this form.
- class import_export_extensions.admin.forms.import_job_admin_form.ImportJobAdminForm(instance: ImportJob, *args, **kwargs)
Admin form for
ImportJob
model.Adds custom import_progressbar field that displays current import progress using AJAX requests to specified endpoint. Fields widget is defined in __init__ method.
- property media
Return all media required to render the widgets on this form.
- class import_export_extensions.admin.forms.import_admin_form.ForceImportForm(import_formats, *args, **kwargs)
Import form with force_import option.
- property media
Return all media required to render the widgets on this form.
- class import_export_extensions.admin.mixins.types.ModelInfo(meta: Options)
Contain base info about imported model.
- property app_label
App label of model.
- property app_model_name: str
Return url name.
- property name: str
Get name of model.
- class import_export_extensions.admin.mixins.export_mixin.CeleryExportAdminMixin(*args, **kwargs)
Admin mixin for celery export.
- Admin export work-flow is:
GET celery_export_action() - display form with format type input
- POST celery_export_action() - create ExportJob and starts data export
This view redirects to next view:
- GET celery_export_job_status_view() - display ExportJob status (with
progress bar). When data exporting is done, redirect to next view:
- GET celery_export_job_results_view() - display export results. If no
errors - success message and link to the file with exported data. If errors - traceback and error message.
- celery_export_action(request, *args, **kwargs)
Show and handle export.
GET: show export form with format_type input POST: create ExportJob instance and redirect to it’s status
- changelist_view(request: WSGIRequest, context: dict[str, Any] | None = None)
Add the check for permission to changelist template context.
- create_export_job(request: WSGIRequest, resource_class: Type[CeleryResource | CeleryModelResource], resource_kwargs: dict[str, Any], file_format: Type[Format]) ExportJob
Create and return instance of export job with chosen format.
- export_job_results_view(request: WSGIRequest, job_id: int, *args, **kwargs) HttpResponse
Display export results.
- GET-request:
show message
if no errors - show file link
if errors - show traceback and error
- export_job_status_view(request: WSGIRequest, job_id: int, **kwargs) HttpResponse
View to track export job status.
Displays current export job status and progress (using JS + another view).
If job result is ready - redirects to another page to see results.
- get_context_data(request: WSGIRequest, **kwargs) dict[str, Any]
Get context data.
- get_export_job(request: WSGIRequest, job_id: int) ExportJob
Get ExportJob instance.
- Raises:
Http404
- get_export_resource_kwargs(request, *args, **kwargs)
Provide escape settings to resource kwargs.
- get_urls()
Return list of urls.
- /<model/celery-export/:
ExportForm (‘export_action’ method)
- /<model>/celery-export/<ID>/:
status of ExportJob and progress bar (‘export_job_status_view’)
- /<model>/celery-export/<ID>/results/:
table with export results (errors)
- has_export_permission(request)
Returns whether a request has export permission.
- class import_export_extensions.admin.mixins.import_export_mixin.CeleryImportExportMixin(*args, **kwargs)
Import and export mixin.
- class import_export_extensions.admin.mixins.import_mixin.CeleryImportAdminMixin(*args, **kwargs)
Admin mixin for celery import.
Admin import work-flow is:
GET
celery_import_action()
- display form with import file input- POST
celery_import_action()
- save file and create ImportJob. This view redirects to next view:
- GET
celery_import_job_status_view()
- display ImportJob status (with progress bar and critical errors occurred). When data parsing is done, redirect to next view:
- GET
celery_import_job_results_view()
- display rows that will be imported and data parse errors. If no errors - next step. If errors - display same form as in
import_action()
- POST
celery_import_job_results_view()
- start data importing and redirect back to GET
celery_import_job_status_view()
with progress bar and import totals.
- celery_import_action(request: WSGIRequest, *args, **kwargs)
Show and handle ImportForm.
- GET:
show import form with data_file input form
- POST:
create ImportJob instance and redirect to it’s status
- celery_import_job_results_view(request: WSGIRequest, job_id: int, *args, **kwargs) HttpResponse
Display table with import results and import confirm form.
- GET-request:
show row results
if data valid - show import confirmation form
if data invalid - show ImportForm for uploading other file
- POST-request:
start data importing if data is correct
- celery_import_job_status_view(request: WSGIRequest, job_id: int, **kwargs) HttpResponse
View to track import job status.
Displays current import job status and progress (using JS + another view).
If job result is ready - redirects to another page to see results.
Also generates admin log entries if the job has IMPORTED status.
- changelist_view(request: WSGIRequest, context: dict[str, Any] | None = None)
Add the check for permission to changelist template context.
- create_import_job(request: WSGIRequest, form: Form, resource: CeleryResource | CeleryModelResource)
Create and return instance of import job.
- get_context_data(request: WSGIRequest, **kwargs) dict[str, Any]
Get context data.
- get_import_context_data(**kwargs)
Get context for import data.
- get_import_job(request: WSGIRequest, job_id: int) ImportJob
Get ImportJob instance.
- Raises:
Http404
- get_urls()
Return list of urls.
- /<model>/<celery-import>/:
ImportForm (‘celery_import_action’ method)
- /<model>/<celery-import>/<ID>/:
status of ImportJob and progress bar (‘celery_import_job_status_view’)
- /<model>/<celery-import>/<ID>/results/:
table with import results (errors) and import confirmation (‘celery_import_job_results_view’)
- has_import_permission(request)
Returns whether a request has import permission.
- POST
- class import_export_extensions.admin.widgets.ProgressBarWidget(*args, **kwargs)
Widget for progress bar field.
Value for progress_bar element is changed using JS code.
- class Media
Class with custom assets for widget.
- render(*args, **kwargs) str
Render HTML5 progress element.
Additionally, method provides hidden import_job_url and export_job_url value that is used in js/admin/progress_bar.js to send GET requests.