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(query_or_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))
# To save memory in redis you can also pass just the query instead of the QuerySet/list
django_rq.enqueue(export, users.query, ('full_name', 'profile_picture', 'team.name', 'date_joined.isoformat'), callback, timedelta(days=2))
```
Metadata
Release files for django-csv-exporter 1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-csv-exporter-1.2.tar.gz | 3.6 kB | Without provenance | Details for django-csv-exporter-1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_csv_exporter-1.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for django_csv_exporter-1.2-py2.py3-none-any.whl |
Total release size: 9.2 kB
Release files / django-csv-exporter-1.2.tar.gz
| Download URL | django-csv-exporter-1.2.tar.gz |
|---|---|
| Size | 3.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6861a2cfe1614115b3fff87734a1851fd98e99310aab66fb79ab9a337e01a74
|
|
BLAKE2b-256 checksum How to use checksums |
59c122a001b3c52ecda330f5ea792fb4d9b420cec4f44b5862af4fd7e2a50c51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_csv_exporter-1.2-py2.py3-none-any.whl
| Download URL | django_csv_exporter-1.2-py2.py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
c926a350b0d1ecc1b228538a8d7151abf68805ada3434145a961c934c6ca2c12
|
|
BLAKE2b-256 checksum How to use checksums |
d3b25d93272a6726ccb0a1bba01c1c34cfb9d6109a2113dc4768262f5113d953
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-csv-exporter 1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.