A simple python module for writing querysets to csv
Project description
django-queryset-csv
===================
a CSV exporter for django querysets.
This tool was created out of repeatedly needing to do the following in django:
1. write CSV data that is based on single-table querysets.
2. automatically encode unicode characters to utf-8
3. create a shortcut to render a queryset to a CSV HTTP response
## usage
Perform all filtering and field authorization in your view using `.filter()` and `.values()`.
Then, use `render_to_csv_response` to turn a queryset into a respone with a CSV attachment.
Pass it a `QuerySet` or `ValuesQuerySet` instance.
```python
from djqscsv import render_to_csv_response
def csv_view(request):
qs = Foo.objects.filter(bar=True).values('id', 'bar')
return render_to_csv_response(qs)
```
## todo
django-queryset-csv will be ready for stable release when the following are complete:
1. unit test coverage reaches 100%
2. test coverage is tracked by a CI server
3. custom column headers are supported (currently column headers are always field names)
4. model methods and foreign key field values are supported (or a decision is made not to)
5. CSV files are viewable in MS Excel, which may require modifying the first few bytes of the file.
6. the package is uploaded to pypi.
===================
a CSV exporter for django querysets.
This tool was created out of repeatedly needing to do the following in django:
1. write CSV data that is based on single-table querysets.
2. automatically encode unicode characters to utf-8
3. create a shortcut to render a queryset to a CSV HTTP response
## usage
Perform all filtering and field authorization in your view using `.filter()` and `.values()`.
Then, use `render_to_csv_response` to turn a queryset into a respone with a CSV attachment.
Pass it a `QuerySet` or `ValuesQuerySet` instance.
```python
from djqscsv import render_to_csv_response
def csv_view(request):
qs = Foo.objects.filter(bar=True).values('id', 'bar')
return render_to_csv_response(qs)
```
## todo
django-queryset-csv will be ready for stable release when the following are complete:
1. unit test coverage reaches 100%
2. test coverage is tracked by a CI server
3. custom column headers are supported (currently column headers are always field names)
4. model methods and foreign key field values are supported (or a decision is made not to)
5. CSV files are viewable in MS Excel, which may require modifying the first few bytes of the file.
6. the package is uploaded to pypi.
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
Close
Hashes for django-queryset-csv-0.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a78183f1ee50885230c50fb9cf62415ca95c8474f43c9daeed6d4089cd8f27c |
|
MD5 | 7fddfe236cd9dd653d1664eb8dca9646 |
|
BLAKE2b-256 | 4d09d3513f742fe45c291e1f4b0f3181d42b1c35b5b1472c678045ee64826036 |