django-exportdata¶
App for export data in csv files from models with selected fields and custom filtration.
Useful for create reports and calculate some statistic data for external sources.
Contents¶
Installation¶
This app works with python 2.6-2.7, Django 1.3 and higher.
Recommended way to install is via pip:
pip install django-exportdata
And add exportdata
to INSTALLED_APPS
in settings.py
Usage¶
Command syntax:
$ python manage.py exportdata <app.Model> [options]
Basic¶
Run for export all model data in ~/exportdata/app.Model.csv file:
$ python manage.py exportdata app.Model
Advanced¶
--fields
option¶
You can select fields in model for export. By default, if --fields
option is not set – export all fields.
Option support FK-fields, model methods, properties, and decorated methods.
Example¶
$ python manage.py exportdata app.model --fields=pk,model_field,get_absolute_url,method_property,fk__field
--filters
option¶
You can set custom filtration (based on model manager methods or filter(field=value)
filtration).
Example¶
$ python manage.py exportdata app.model --filters=active,paid,field=value,fk__field__gte=value
--ordering
option¶
You can set sort for order_by
method.
Example¶
$ python manage.py exportdata app.model --ordering=-created_on,title
--range
option¶
Set “from and to” diapason values primary keys (pks) for export or set comma-separated values.
Examples¶
“From and to” range:
$ python manage.py exportdata app.model --range=1-100
Comma separated values:
$ python manage.py exportdata app.model --range=1,2,3,4,5
Serializers¶
Currently django-exportdata
supports only csv files export.
There are plans to add other serialization in future releases.
Changelog¶
0.2 (2013-07-20)¶
- Moved many operations in methods with improvements
- Added advanced fitration for
--filters
option - Added support
--range
option - Added
--filepath
option for set file for save data - Added
--permalinks
option for getmodels.permalink
decorated fields - Added help for all options and for the command
- Added package documentation on ReadTheDocs
0.1 (2013-07-13)¶
Initial release