Skip to main content

Django Export Edit Import

A reusable Django app that enables export, edit and import (Excel) workflow for Django models. This package provides a seamless way to export model data to Excel files, allow external editing, and import the modified data back into your Django application.

Features

  • Export Django model data to Excel files
  • Track export/import operations with detailed status information
  • Handle import errors gracefully with error reporting
  • Support for bulk operations (create, update, delete)
  • Built-in file generation status tracking
  • Integration with Celery for background processing
  • Comprehensive error handling and logging

Quick Start

Installation

Install the package using pip:

pip install django-export-edit-import

Or if installing from source:

git clone https://your.git.server/django-export-edit-import
cd django-export-edit-import
pip install -e .

Django Configuration

Add the app to your Django project's INSTALLED_APPS:

# settings.py
INSTALLED_APPS = [
    # ... your other apps
    'export_edit_import',
    # ... rest of your apps
]

Database Setup

Run migrations to create the necessary database tables:

# Generate migrations (if needed)
python manage.py makemigrations export_edit_import

# Apply migrations
python manage.py migrate

Dependencies

This package requires the following dependencies:

  • Django >= 4.2
  • pandas >= 2.0
  • openpyxl >= 3.1

Basic Usage

Exporting Data

from export_edit_import.models import GeneratedExportFile
from django.contrib.contenttypes.models import ContentType
from myapp.models import MyModel

# Create an export file
content_type = ContentType.objects.get_for_model(MyModel)
export_file = GeneratedExportFile.objects.create(
    related_model_type=content_type
)

# Process the export (typically done in a background task)
# ... your export logic here

Importing Data

from export_edit_import.models import GeneratedImportFile
from django.contrib.contenttypes.models import ContentType

# Create an import file
import_file = GeneratedImportFile.objects.create(
    related_model_type=content_type,
    file=uploaded_file
)

# Process the import (typically done in a background task)
# ... your import logic here

Models Overview

GeneratedFile (Abstract Base)

  • Base class for tracking file generation operations
  • Includes status tracking, error handling, and task management
  • Supports integration with Celery for background processing

GeneratedExportFile

  • Tracks Excel export operations
  • Provides methods to check if export files are up-to-date
  • Handles file reuse logic to avoid unnecessary regenerations

GeneratedImportFile

  • Tracks Excel import operations
  • Provides detailed statistics (created, updated, deleted rows)
  • Handles error file generation for failed import rows

File Status Options

  • PENDING: Operation is queued or in progress
  • COMPLETED: Operation completed successfully
  • FAILED: Operation failed with errors
  • COMPLETED_WITH_ERRORS: Operation completed but with some errors

Migration Commands

Initial Setup

python manage.py makemigrations export_edit_import
python manage.py migrate

After Updates

python manage.py makemigrations
python manage.py migrate

Upgrade Path

From Development to 1.0.0

This is the initial release. No upgrade path needed.

Future Versions

When upgrading to future versions:

  1. Review the changelog below
  2. Update your requirements/dependencies
  3. Run pip install -U django-export-edit-import
  4. Run python manage.py makemigrations
  5. Run python manage.py migrate
  6. Test your implementation thoroughly

Changelog

v1.0.0 (Initial Release)

  • ✨ Initial release of django-export-edit-import
  • 📦 Core export/import functionality
  • 🗄️ Database models for tracking operations
  • 📊 Support for Excel file processing
  • 🔄 Status tracking and error handling
  • 📋 Integration with Django's ContentTypes framework
  • ⚡ Background task support preparation

Future Releases

  • v1.1.0 - Enhanced error reporting and validation
  • v1.2.0 - Additional file format support
  • v2.0.0 - Breaking changes and major improvements

Development

Requirements

  • Python >= 3.9
  • Django >= 4.2

Development Setup

pip install -e .[dev]

Running Tests

pytest

License

MIT License. See LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Metadata

Release files for django-export-edit-import 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-export-edit-import 1.0.2
File Size Uploaded
django_export_edit_import-1.0.2.tar.gz 20.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-export-edit-import 1.0.2
File Interpreter ABI Platform
django_export_edit_import-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 44.9 kB

Release files / django_export_edit_import-1.0.2.tar.gz

Download URL django_export_edit_import-1.0.2.tar.gz
Size 20.6 kB
Tags Source
SHA-256 checksum
How to use checksums
dfc643eb419ba98e3770e6bfde1b2324f0c49d67ed8dc57656dc02759f9a8f3c
BLAKE2b-256 checksum
How to use checksums
61dc9a6a8bcb362c111767597c958edc59ac07936cb69bc17e336fe70179918b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release files / django_export_edit_import-1.0.2-py3-none-any.whl

Download URL django_export_edit_import-1.0.2-py3-none-any.whl
Size 24.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8b183f3a65006a6eeef6fedb1fdfd436e1c13be6b4b4f867e5c9d3127f6498b
BLAKE2b-256 checksum
How to use checksums
c46416c4328f9c098858426035d30923c52e6c414483c867d2edb3f79fb0177d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page