Is there a way to have fixtures in raw Python to, for example, create initial data from external files? I have fixtures in JSON presently, and it might actually be more effective to migrate them to a kind of CSV file and have Python parse these and insert them. Is there a way to do this in Django?
Asked
Active
Viewed 189 times
2 Answers
1
I just released library for exactly this purposes https://pypi.python.org/pypi/django_pyfixture/
You'll get manage.py loaddata_py <fixturename>
for console API and py_fixtures = [<list of fixtures>]
for your tests.

Konstantine Rybnikov
- 2,457
- 1
- 22
- 29
1
Catch the post_syncdb
signal and do your work in the handler.

Ignacio Vazquez-Abrams
- 776,304
- 153
- 1,341
- 1,358
-
I can't have an `initial_data.py` file or something like that? Is there a way to do this without involving signals? – Naftuli Kay Mar 12 '12 at 20:31
-
Django only supports [XML, YAML, JSON, or SQL](https://docs.djangoproject.com/en/dev/howto/initial-data/) as initial data. – Ignacio Vazquez-Abrams Mar 12 '12 at 20:33
-
Ok, great. I thought I had heard that they supported Python fixtures, but I guess this works too :) – Naftuli Kay Mar 12 '12 at 20:33