Skip to main content

django-dataio

django-dataio is a Django utility package for data import and export.
It allows you to easily export your Django model data into Excel, CSV, JSON, etc., and import data from these formats back into your models.

Installation

    pip install django-dataio

Features

  • Export Django models using configurable fields.
  • Import data into Django models from Excel (and more formats in the future).
  • Extensible architecture: add your own exporters/importers.

How to Use

django-dataio provides a mixin DjangoDataIOModelMixin that allows your Django models to export and import data based on configurable fields (ModelField).

You simply inherit the mixin in your model and define ModelField entries for the fields you want to manage.

1. Add DjangoDataIOModelMixin to your model

from django.db import models
from django_dataio.mixins import DjangoDataIOModelMixin

class Customer(DjangoDataIOModelMixin, models.Model): # -> Here!
    first_name = models.CharField(max_length=50)
    last_name = models.CharField(max_length=50)
    email = models.EmailField(unique=True)

2. Register fields in ModelField

from django.contrib.contenttypes.models import ContentType
from django_dataio.models import ModelField
from my_app.models import Customer

customer_type = ContentType.objects.get_for_model(Customer)

ModelField.objects.create(name="first_name", model=customer_type, xp=1)
ModelField.objects.create(name="last_name", model=customer_type, xp=2)
ModelField.objects.create(name="email", model=customer_type, xp=3)

# xp is the position/order of the field in export/import files.

3. Export data

from pathlib import Path
from my_app.models import Customer

# Export all customers to Excel
file_path: Path = Customer.data_export('excel')
print(f"Exported file: {file_path}")

4. Import data

from pathlib import Path
from my_app.models import Customer

file_to_import = Path("/tmp/customers.xlsx")

# Import data back into the model
imported_count = Customer.data_import(file_to_import, import_name='excel')
print(f"{imported_count} records imported")

You can add custom exporters or importers by subclassing the base classes:

from django_dataio.handlers.imports import BaseImporter
from django_dataio.handlers.exports import BaseExporter

class CSVExporter(BaseExporter):
    ...

class CSVImporter(BaseImporter):
    ...

Check the Export | Import handlers implementation for details.


TODO / Update

Metadata

Release files for django-dataio 0.0.1

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-dataio 0.0.1
File Size Uploaded Provenance Actions
django_dataio-0.0.1.tar.gz 10.0 kB Without provenance Details for django_dataio-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-dataio 0.0.1
File Interpreter ABI Platform Actions
django_dataio-0.0.1-py3-none-any.whl Python 3 none any Details for django_dataio-0.0.1-py3-none-any.whl

Total release size: 24.2 kB

Release files / django_dataio-0.0.1.tar.gz

Download URL django_dataio-0.0.1.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9dd77fdb8016d2a4e938ee30e6f280dab9bf72b192a87bea34eeec2160864522
BLAKE2b-256 checksum
How to use checksums
861518bf08b1d2b15f9839497789864aaa019c6ce69a045eaffc29ada3ad90d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / django_dataio-0.0.1-py3-none-any.whl

Download URL django_dataio-0.0.1-py3-none-any.whl
Size 14.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a03f11dee4ba94dafad0866da7899616eaf7597f075d761069ac9ed50bd03aa
BLAKE2b-256 checksum
How to use checksums
3a5441c8269c7a2338680d8b2343858757ac9b50b6af6157ec4173121e384bdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for django-dataio 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

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