Skip to main content

A django package to export data in a csv with File export.

Project description

# CSV Exporter

This Django package is a model exporter that can be run in a delayed task and emails a link to the resulting zip file containing a csv and all files.

## How to use

### To install the package

```
pip install django-csv-exporter
```

### To use the package

```
def export(queryset, attributes, callback=None, timedelta=datetime.timedelta(days=2)):
```

```
from datetime import timedelta
from functools import partial
from csv_exporter import export, send_email_to_user

users = UserProfile.objects.filter(team='myteam', active=True)
callback = partial(send_email_to_user, ['email1@gmail.com', 'email2@gmail.com'])
zip_url = export(users, ('full_name', 'profile_picture', 'team.name', 'date_joined.isoformat'), callback, timedelta(days=2))
```

The function `send_email_to_user` is a helper function to send the zip_url to the users. The callback to export needs to accept the parameters (zip_url, timedelta). Timedelta is a length of time the url is valid for. Expiration works only for django-storages using s3-boto, otherwise the regular url is returned.

### With Django RQ

```
import django_rq
django_rq.enqueue(export, users, ('full_name', 'profile_picture', 'team.name', 'date_joined.isoformat'), callback, timedelta(days=2))
```

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

django-csv-exporter-1.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

django_csv_exporter-1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

django_csv_exporter-1.1-py2.py3-none-any.whl (5.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file django-csv-exporter-1.1.tar.gz.

File metadata

File hashes

Hashes for django-csv-exporter-1.1.tar.gz
Algorithm Hash digest
SHA256 5c2df43876644cbf35e08ad8fd060623c30584879b6d4e597320ed1ebf102c43
MD5 4cc804001552430567e65f2950023d83
BLAKE2b-256 2372defdd1b6b3945f5b6bc2bf4b0629e1d5893e73bef006c6e63540aacb632f

See more details on using hashes here.

File details

Details for the file django_csv_exporter-1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_csv_exporter-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e9512ab7f12c4cfc318996cff8d4255264b71894b69232794fcf678fd70b54f
MD5 3721655af318ed6b40c6e65865e772c4
BLAKE2b-256 99fafa84ed08f353d3a567a9fa0c2f357052a43a853213b0b4248ade918a224d

See more details on using hashes here.

File details

Details for the file django_csv_exporter-1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for django_csv_exporter-1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 eb21d6e1752d7939849b7a05c157f4b8d81d629b6c15a98a7ff2e519360c96ed
MD5 88a1bf66a66b76d9e7e5180fc13c97c4
BLAKE2b-256 ee861f461a3f185db381ab9e022db8a1c62ae23e572bb5e3961392d8c7976335

See more details on using hashes here.

Supported by

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