Skip to main content

Import/Export feature for django models

Project description

model-import-export

Imports and Exports django model to excel and csv

Requirement

python >= 3
Django 1.11.5, >= 2.11

Installation

pip install model-import-export

Usage

Creating resources

In your example_app/resources.py

from model_import_export.resources import ModelResource, ForeignKeyResource, ManyToManyResource

from dashboard.models import *

class UserResource(ModelResource):

	class Meta:
		model = User
		fields = '__all__'

Exporting model

from .resources import UserResource

queryset = User.objects.all()
resource = UserResource(queryset)
resource.to_excel('users.xlsx')

Importing model

resource = UserResource()
resource.from_excel('users.xlsx')

Model Import/Export Example

GitHub model_import_export_example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

model_import_export-0.1.4.tar.gz (5.6 kB view hashes)

Uploaded source

Built Distributions

model_import_export-0.1.4-py3.7.egg (10.9 kB view hashes)

Uploaded 0 1 4

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page