Queryset CSV is a simple module to allow Django Querysets to be exported as CSV files.
Installation
pip install intouch-queryset-csv
Then add the app to your installed apps
intouch.queryset_csv
Usage
There are several ways to use the Queryset csv exporter.
Render to response
The most basic usage is to call the function
queryset_as_csv_response
This function accepts a queryset as a parameter, along with a filename and whether the file is to be streamed. It returns an HTTPResponse object, so should be called at the end of a view function to offer the download to the client.
Admin Action
An action is provided for the Django admin site. There are 3 ways of including it:
The function
export_model_as_csvcan be added to your custom admin class’s actionsThe
CsvExporterAdminclass can be inherited to provide the actionSetting
CSV_EXPORT_ADMIN_ACTION_AVAILABLE=Truein your django settings module will make the action available to all registered admin classes.
The action will simply export all objects of the selected model to csv (as a stream)
Why create this code rather than use an existing CSV export project?
Licensing - Other CSV export packages encountered are Licensed under the GNU GPL. The GPL is incompatible with the desired usage, so a this was written from scratch.
Functionality - Existing CSV packages are not designed to handle very large querysets, the option to steam querysets is essential for models with thousands of entries.
Simplicity - This package has no dependencies other than django itself, and the requirements are to be kept to a minimum in future versions (preferably solely django). It is also designed to require as little effort as possible to use.
Currency - The package is written and tested using the latest versions of Python and Django. While it may work with older versions, no special effort will be expended to force compatibility with old versions.
Settings
CSV_EXPORT_ADMIN_ACTION_AVAILABLE- If True, adds the CSV Export action to all admin pages by defaultQUERYSET_CSV_DATE_FORMAT- Set the format to use when outputting datetime.datetime objects, defaults to"%d-%m-%Y %H:%M:%S"
Tested Versions
Django versions 1.11-2.2 should be supported, Python 3 versions supported as per the Django releases.
Metadata
Release files for intouch-queryset-csv 0.3.1
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 |
|---|---|---|---|---|
| intouch_queryset_csv-0.3.1.tar.gz | 9.2 kB | Without provenance | Details for intouch_queryset_csv-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| intouch_queryset_csv-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for intouch_queryset_csv-0.3.1-py3-none-any.whl |
Total release size: 18.7 kB
Release files / intouch_queryset_csv-0.3.1.tar.gz
| Download URL | intouch_queryset_csv-0.3.1.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c2884a17872746d127c13b09b41cb6dafa2a58efb2930c3c8ea9bcb23dd432d
|
|
BLAKE2b-256 checksum How to use checksums |
f9c8caa0b6681bf5da959d6ccde5747f43f8b90ab8e14a8ba2e28da6405392f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
|
Release files / intouch_queryset_csv-0.3.1-py3-none-any.whl
| Download URL | intouch_queryset_csv-0.3.1-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1bfbedb3ec1ab58c489a46e949c471c8dc4436807fe9b28626f49ad4abd5191
|
|
BLAKE2b-256 checksum How to use checksums |
befc462813ff7d94ac2627023f958d38bc5a5b05c814cd876c9d0a561527f66e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.6
|
Security for intouch-queryset-csv 0.3.1
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.