UNICEF Rest Export
Django Rest Framework data export package that handles export/rendering to JSON, CSV, XLS, and HTML
Installation
pip install unicef-rest-export
Setup
Add unicef_rest_export to INSTALLED_APPS in settings
INSTALLED_APPS = [
...
'unicef_rest_export',
]
Usage
A sample model view;
class AuthorView(ExportView):
queryset = Author.objects.all()
serializer_class = serializers.AuthorSerializer
A sample model viewset;
class AuthorViewSet(ExportViewSet):
queryset = Author.objects.all()
serializer_class = serializers.AuthorSerializer
To override or limit the renderers allowed, add EXPORT_RENDERERS to settings. The current default is;
EXPORT_RENDERERS = (
"unicef_rest_export.renderers.ExportHTMLRenderer",
"unicef_rest_export.renderers.ExportCSVRenderer",
"unicef_rest_export.renderers.ExportJSONRenderer",
"unicef_rest_export.renderers.ExportExcelRenderer",
)
The following is a sample of transforming data;
class AuthorTransformView(ExportView):
queryset = Author.objects.all()
serializer_class = serializers.AuthorSerializer
def transform_books(self, data):
return [d["name"] for d in data]
def transform_dataset(self, dataset):
dataset.add_formatter("books", self.transform_books)
return dataset
Contributing
Environment Setup
To install the necessary libraries
$ make install
Coding Standards
See [PEP 8 Style Guide for Python Code](https://www.python.org/dev/peps/pep-0008/) for complete details on the coding standards.
To run checks on the code to ensure code is in compliance
$ make lint
Testing
Testing is important and tests are located in tests/ directory and can be run with;
$ make test
Coverage report is viewable in build/coverage directory, and can be generated with;
Project Links
Continuos Integration - https://circleci.com/gh/unicef/unicef-rest-export/tree/develop
Source Code - https://github.com/unicef/unicef-rest-export
Thanks to
[django-rest-pandas](https://github.com/wq/django-rest-pandas) as a lot of the code was borrowed from that package.
Metadata
Release files for unicef-rest-export 0.6
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 |
|---|---|---|---|---|
| unicef_rest_export-0.6.tar.gz | 10.4 kB | Without provenance | Details for unicef_rest_export-0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| unicef_rest_export-0.6-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for unicef_rest_export-0.6-py2.py3-none-any.whl |
Total release size: 19.3 kB
Release files / unicef_rest_export-0.6.tar.gz
| Download URL | unicef_rest_export-0.6.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a2972630d99dce927becaa70e7fb785116401f80beff77b13a5ecfc7139d983
|
|
BLAKE2b-256 checksum How to use checksums |
2b82309f4226f458d4a54653836c0367c1d8761b07424c80091d499d5b3b4325
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.9
|
Release files / unicef_rest_export-0.6-py2.py3-none-any.whl
| Download URL | unicef_rest_export-0.6-py2.py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
67d07341b586de51f6d5ef3ed00599bbe49ae34c4ccc1a0934fcbb839c686faa
|
|
BLAKE2b-256 checksum How to use checksums |
133daa64be7a1fa2d098f9a0b6e694180aa1042d299437cf28bb0a6c95855eab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.9
|
Security for unicef-rest-export 0.6
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.