Django package that handles exporting of data
Project description
# 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.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
unicef_rest_export-0.5.1.tar.gz
(20.7 kB
view details)
File details
Details for the file unicef_rest_export-0.5.1.tar.gz
.
File metadata
- Download URL: unicef_rest_export-0.5.1.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81bcc3a5cc914e2cbd2ed57c681b6556b602fb0da5f19d10a1531717634e9940 |
|
MD5 | e2c27e5c121a971cdba41dc20626c5fd |
|
BLAKE2b-256 | 11e0e4036b9f53143d15dbed3040a6a316ef38b1b77d070f87d3584a793bc5c9 |