2

I have a few apps set up, to one of which I just added a fixture. I created an "initial_data.yaml" file in a subdirectory "fixtures" under the app folder, so the full path is project_dir\apps\job\fixtures\initial_data.yaml.

I've tried both

python manage.py syncdb

and

python manage.py schemamigration job --auto

and both of them give me:

No fixtures found.

What am I doing wrong, here?

Paul Zaczkowski
  • 2,848
  • 1
  • 25
  • 26
  • How does your INSTALLED_APPS setting look? Did you create the fixture by hand? If so check it through a yaml parser for syntax errors. – Torsten Engelbrecht May 05 '11 at 00:51
  • @Torsten `INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Uncomment the next line to enable the admin: 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'django.contrib.webdesign', 'south', 'haystack', # Our Apps # 'jobfinder.apps.job', 'jobfinder.apps.profile', )` – Paul Zaczkowski May 05 '11 at 01:21
  • Went through a YAML parser, and corrected all my errors, still saying that it couldn't be found. Figured out that I needed to have PyYaml installed, but then decided to just go the JSON route. I feel like there's a piece to the puzzle that I'm missing here :/ – Paul Zaczkowski May 05 '11 at 01:22
  • Well, I figured out what was wrong. I simply needed to define `FIXTURE_DIRS` in my `setting.py`. For whatever reason, this isn't stated in the docs (I was under the assumption it would look for fixtures under app directories automatically, but it seems that's not the case). Maybe it would be a considerable contribution to Django ^_^. I ended up using the YAML file after-all. – Paul Zaczkowski May 05 '11 at 01:33
  • @paul Write an answer and put that info in it and mark it correct. It might help someone else with the same problem. – James Khoury May 05 '11 at 02:19
  • I don't think you need PyYAML. I am a little confused about your apps in `INSTALLED_APPS` + your project/app structure. My guess that if you do `python manage.py schemamigration job --auto` it will simply not resolve the app `job` correctly. Did you try `python manage.py schemamigration jobfinder.apps.job --auto` or just `python manage.py schemamigration apps.job --auto`? – Torsten Engelbrecht May 05 '11 at 02:56
  • @James Khoury I will once my "new users must wait 8 hours" period is up :). @ Torsten south appears to be working fine with simply "jobs". All of _my_ apps are under an apps subfolder in the root project folder. I find it easier to manage, personally. – Paul Zaczkowski May 05 '11 at 03:16

4 Answers4

2

Do you install pyYAML ?

http://pyyaml.org/wiki/PyYAML

manage.py needs yaml-parser for load initial_data.yaml.

99blues
  • 36
  • 1
  • Just wanted to point out that this is documented in the Django docs as well: http://docs.djangoproject.com/en/1.3/topics/serialization/#id1 Also, it is important to include the FIXTURE_DIRS setting. Hopefully this will help out anyone else that might this issue in the future :) – Paul Zaczkowski May 24 '11 at 19:05
  • I'm in the same directory with the initial_data.yaml to manage.py. I do not use FIXTURE_DIRS. – 99blues May 25 '11 at 05:14
1

Django documentation clearly states:

By default, Django looks in the fixtures directory inside each app for fixtures.

But I have found that it's not true. If You don't define FIXTURE_DIRS in settings.py, then django will look for initial_data.yaml in the same directory where manage.py and settings.py are. I had this issue with django 1.3.1.

You also need to have a python yaml parser installed or django will ignore fixtures in yaml format. If You are using Ubuntu, You can install the parser by issuing the following command in the console:

sudo apt-get install python-yaml
Paweł Polewicz
  • 3,711
  • 2
  • 20
  • 24
0

i think it needs to go in

/project/job/fixtures/

assuming your app is named job

James Khoury
  • 21,330
  • 4
  • 34
  • 65
0

Try the following and see how you go:

Dump your existing data, empty your DB and then try syncdb again (if you are happy to clear your DB):

python manage.py dumpdata
python manage.py syncdb

Does that work? If so, you have a 'blueprint' fixture file.

If not could you let us know which version of Django you are using?

Longestline
  • 270
  • 2
  • 9