> For the complete documentation index, see [llms.txt](https://www.dicas-de-django.com.br/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.dicas-de-django.com.br/100-34-export-csv.md).

# 100-34-export-csv

## Dica 34 - Exportando CSV

[![](/files/-MfuAP1e7W4erW9hf6Ic)](https://youtu.be/eS4U_kBNWu8)

### Exportando CSV

```python
import csv

with open('/tmp/products_out.csv', 'w') as f:
    csv_writer = csv.writer(f)

    csv_writer.writerow(['title', 'price'])
    for product in Product.objects.all():
        csv_writer.writerow([product.title, product.price])
```

### Exportando CSV pelo Admin

Use o [django-import-export](https://django-import-export.readthedocs.io/en/latest/)

## Exportando CSV
