Django management command to export choosen data from one table
Project description
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
Export from another database than ‘default’:
./manage.py dumpdata_one app_name.model_name --database=other_database
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
Built Distribution
File details
Details for the file django-dumpdata-one-0.8.6.tar.gz
.
File metadata
- Download URL: django-dumpdata-one-0.8.6.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e29024d8d2db5771cb22e1b3cd4c0c0b2a0c50f0e3a9469cf4f0c99e7c307eb6 |
|
MD5 | cf588e2fb64e069d0bc86c060e4518da |
|
BLAKE2b-256 | 98fb140af36b5a0197df28bff6cfdf78035b0012fb1105ec322cb4c5e2e340c0 |
File details
Details for the file django_dumpdata_one-0.8.6-py3-none-any.whl
.
File metadata
- Download URL: django_dumpdata_one-0.8.6-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa9c972d076a2acbfdb1933cd6211c5a541c6b7ad3ce9138cd6b1a2ffd958ee7 |
|
MD5 | c120393b48a2bd04f6457af6d472dca3 |
|
BLAKE2b-256 | 3d42cf3078ac0904e19e696f200cd6350ed2d7d4585919cb6fc5e28d2b01d5c7 |