{"id":16744813,"url":"https://github.com/marteinn/django-csvexport","last_synced_at":"2025-06-23T05:05:44.515Z","repository":{"id":28764246,"uuid":"32286531","full_name":"marteinn/django-csvexport","owner":"marteinn","description":"Convert Django models to csv files","archived":false,"fork":false,"pushed_at":"2018-05-09T05:03:45.000Z","size":30,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-23T05:03:30.376Z","etag":null,"topics":["csv","django","exporter"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marteinn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-15T22:06:12.000Z","updated_at":"2022-08-22T01:53:55.000Z","dependencies_parsed_at":"2022-09-03T09:40:58.382Z","dependency_job_id":null,"html_url":"https://github.com/marteinn/django-csvexport","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/marteinn/django-csvexport","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marteinn%2Fdjango-csvexport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marteinn%2Fdjango-csvexport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marteinn%2Fdjango-csvexport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marteinn%2Fdjango-csvexport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marteinn","download_url":"https://codeload.github.com/marteinn/django-csvexport/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marteinn%2Fdjango-csvexport/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261417566,"owners_count":23155071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["csv","django","exporter"],"created_at":"2024-10-13T01:44:11.699Z","updated_at":"2025-06-23T05:05:39.483Z","avatar_url":"https://github.com/marteinn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/marteinn/django-csvexport.svg?branch=master)](https://travis-ci.org/marteinn/django-csvexport)\n[![PyPI version](https://badge.fury.io/py/django-csvexport.svg)](http://badge.fury.io/py/django-csvexport)\n\n# Django-CSVExport\n\nThis is a django extension that simplifies model to csv conversions.\n\n\n## Requirements\n- Python 2.7 / 3.3+\n- Django 1.8+\n\n\n## Example:\n\n### Simple usage:\n\nGenerate csv string from a model:\n\n```python\nfrom csvexport.exports import ModelCSVExporter\n\nrecords = Record.objects.all()\nexp = ModelExporter(queryset=records)\nf = exp.to_string()\n```\n\n### With specified fields\n\nSame as the previous example, but only expose certain fields:\n\n```python\nfrom csvexport.exports import ModelCSVExporter\n\nclass RecordExporter(ModelCSVExporter):\n    class Meta:\n        fields = [\"album\", \"slug\"]\n        exclude = [\"id\"]\n\n\nrecords = Record.objects.all()\nexp = RecordExporter(queryset=records)\nf = exp.to_string()\n```\n\n### Generating a csv from a view:\n\nThis is a example how you could generate a downloadable csv by requesting a view, using the `render_to_csv` helper.\n\n**urls.py**\n\n```python\nurl(r'^csv/$', 'app.views.gen_csv'),\n```\n\n**views.py**\n\n```python\ndef gen_csv(request):\n    from csvexport.exporters import ModelExporter\n    from csvexport.utils import render_to_csv\n    records = Record.objects.all()\n    exp = ModelExporter(queryset=records)\n    return render_to_csv(exp)\n```\n\n### With custom hydration\n\nIt is also possible to create a custom csv object:\n\n```python\nclass RecordExporter(ModelExporter):\n    class Meta:\n        fields = [\"artist\", \"title\", \"release_year\", \"format\", \"quality\",\n                  \"record_label\", \"comment\", \"venue\", \"url\"]\n\n    def hydrate_entry(self, entry):\n        venue_name = \"\"\n\n        if entry.venue:\n            venue_name = entry.venue.name\n\n        return {\n            \"artist\": entry.album.artist.name,\n            \"title\": entry.album.name,\n            \"release_year\": entry.album.release_year,\n            \"format\": entry.format,\n            \"quality\": entry.quality,\n            \"record_label\": entry.record_label,\n            \"comment\": entry.comment,\n            \"venue\": venue_name,\n        }\n\n\nrecords = Record.objects.all()\nexp = RecordExporter(queryset=records)\nf = exp.to_string()\n\n```\n\n\n## Installation\n\ndjango-csvexport can easily be installed through pip.\n\n    $ pip install django-csvexport\n\n\n## Tests\n\nThis library include tests, just run `python runtests.py`.\n\nYou can also run separate test cases: `runtests.py tests.ViewTestCase`\n\n\n## Contributing\n\nWant to contribute? Awesome. Just send a pull request.\n\n\n## License\n\nDjango-CSVExport is released under the [MIT License](http://www.opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarteinn%2Fdjango-csvexport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarteinn%2Fdjango-csvexport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarteinn%2Fdjango-csvexport/lists"}