Reusable Django app that enables export, edit and import (Excel) workflow.
Project description
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 progressCOMPLETED: Operation completed successfullyFAILED: Operation failed with errorsCOMPLETED_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:
- Review the changelog below
- Update your requirements/dependencies
- Run
pip install -U django-export-edit-import - Run
python manage.py makemigrations - Run
python manage.py migrate - 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.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_export_edit_import-1.0.2.tar.gz.
File metadata
- Download URL: django_export_edit_import-1.0.2.tar.gz
- Upload date:
- Size: 20.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfc643eb419ba98e3770e6bfde1b2324f0c49d67ed8dc57656dc02759f9a8f3c
|
|
| MD5 |
42ca1abe76c60a49336bef75cb4509e7
|
|
| BLAKE2b-256 |
61dc9a6a8bcb362c111767597c958edc59ac07936cb69bc17e336fe70179918b
|
File details
Details for the file django_export_edit_import-1.0.2-py3-none-any.whl.
File metadata
- Download URL: django_export_edit_import-1.0.2-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8b183f3a65006a6eeef6fedb1fdfd436e1c13be6b4b4f867e5c9d3127f6498b
|
|
| MD5 |
bee738f565b6de38bcf564b38efb7492
|
|
| BLAKE2b-256 |
c46416c4328f9c098858426035d30923c52e6c414483c867d2edb3f79fb0177d
|