For a Django test I'd like to load a fixture, which is in a csv file. What is the best way to do that?
Asked
Active
Viewed 2,560 times
2 Answers
7
Django's built-in fixtures functionality doesn't support CSV. You'd need to process the file automatically using the csv
module, probably in the test's setUp
method.

Daniel Roseman
- 588,541
- 66
- 880
- 895
-
1Obviously this is many years late, but for anyone still looking for something like this, the [django-excel-fixture](https://github.com/SKisContent/django-excel-fixture) may do the trick. You can use native xlsx files. – Sushil Jun 15 '18 at 10:50
1
For easier reuse I'd suggest my Django-PyFixture library. You'd then program your fixture in raw python, but it would semantically look like one more fixture.

Konstantine Rybnikov
- 2,457
- 1
- 22
- 29