Question

I've written a pretty simple Django application called django-locality which takes the headache out of working with countries and territories. It provides a lot of initial data for countries and territories. I just the 0.1 release up to PyPI, and installed it in my project which I'm currently working on. (I basically created it out of a need I found in my original project.)

When I ran syncdb, however, it didn't install any of my fixtures from locality. In the output, it printed "No fixtures found," and no rows were added to the database, though the tables were generated. Is there a reason why Django is missing my initial data? My data lives at locality/fixtures/initial_data.json and installs just fine if running it from it's own dedicated project. As I'm using setuptools to manage dependencies, would it make a difference if I downloaded it as a zipped egg vs. a simple directory layout?


Initially, it seems that my JSON wasn't being included in the egg, and this is why syncdb didn't work. Now, I've fixed that problem, but syncdb is still failing to find any of my fixtures. You can download the egg to see for yourself here. I can't think of any reason why Django would be missing the initial data. You can also view the repository on GitHub. Why isn't Django seeing the fixtures?


When I run syncdb -v 2, I do see that Django sees the egg and looks for the fixtures:

No json fixture 'initial_data' in '/home/rfkrocktk/Desktop/myproject/eggs/django_locality-0.1.1-py2.7.egg/locality/fixtures'.

Is it possible that Django doesn't know how to read from eggs?

Was it helpful?

Solution 2

Ok, as it turns out, Django doesn't know how to look inside zipped egg files. As soon as I extracted the egg file to a directory with its name, things worked.

OTHER TIPS

It looks like your setup.py does not include the initial_data.json as package_data: http://docs.python.org/distutils/setupscript.html#installing-package-data This means when you install from PyPi you won't get the initial_data.json file in your distribution.

I personally find it easier to use source distributions sdist for Django apps. In that case you can list non-Python files which need to be included in the MANIFEST: http://docs.python.org/distutils/sourcedist.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top