Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Django management command to export choosen data from one table

Project description

https://travis-ci.org/ascaliaio/django-dumpdata-one.svg https://codecov.io/gh/ascaliaio/django-dumpdata-one/branch/master/graph/badge.svg

Django Dumpdata One

Custom dumpdata command which allows to exporting from given fields of a model and filter that data using standard Django lookups for filtering.

The exported data structure is compatible with Django dumpdata structure which allows you to use standard loaddata command for import.

Installation

To get the latest stable release from PyPi

pip install django-dumpdata-one

Add dumpdata_one to your INSTALLED_APPS

INSTALLED_APPS = (
    ...,
    "django_dumpdata_one",
)

Usage

Export data:

./manage.py dumpdata_one app_name.model_name --fields=field1,field2 > dump_file.json

Import data:

./manage.py loaddata dump_file.json

How to use filters? If you not familiar take a look at Django Field lookups - https://docs.djangoproject.com/en/3.0/topics/db/queries/#field-lookups

./manage.py dumpdata_one app_name.model_name --fields=field1 --filter=name__icontains=django

./manage.py dumpdata_one app_name.model_name --fields=field1 --filter=name__icontains=django,pk__gt=300

Set order by:

./manage.py dumpdata_one app_name.model_name --fields=field1,field2 --order=field2,field2

Export all fields:

./manage.py dumpdate_one app_name.model_name --fields=*

Limit number of exported records:

./manage.py dumpdata_one app_name.model_name --fields=* --limit=10

Export full file URL:

./manage.py dumpdata_one app_name.model_name --fields=image --full_url=image

Project details


Download files

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

Files for django-dumpdata-one, version 0.8.3
Filename, size File type Python version Upload date Hashes
Filename, size django_dumpdata_one-0.8.3-py3-none-any.whl (5.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-dumpdata-one-0.8.3.tar.gz (7.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page