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 Source

model_import_export-0.1.4-py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page