I can't load fixtures

964 views
Skip to first unread message

Daniel Grace

unread,
Aug 14, 2014, 1:05:30 PM8/14/14
to django...@googlegroups.com
I created a fixtures file called testdata.xml in a fixtures folder, but I can't load the fixtures file into the database.

I placed an __init__.py file in the fixtures folder (not sure about this step, is it needed?)

I put the fixtures directory in settings.py:
FIXTURE_DIRS = (
   '/myapp/fixtures/',
)

I tried two ways to load the fixture, but neither worked:
>python manage.py syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
>python manage.py loaddata "myapp/fixtures/testdata.xml"
C:\myenv\lib\site-packages\django\core\management\commands\loaddata.py:216: User
Warning: No fixture named 'myapp/fixtures/testdata' found.
  warnings.warn("No fixture named '%s' found." % fixture_name)
Installed 0 object(s) from 0 fixture(s)

Any ideas?
Thanks

eprikazc

unread,
Aug 15, 2014, 1:05:15 AM8/15/14
to django...@googlegroups.com
'/myapps/fixtures' is treated as absolute path. Try removing leading slash to make it relative. Either you can write full absolute path to the directory.

thanks,
Eugene

Davide Scatto

unread,
Aug 17, 2014, 3:30:19 AM8/17/14
to django...@googlegroups.com
when you run a test the django fixture discoverer search in all fixture subfolder in apps registered in settings.INSTALLED_APPS.
you don't need __init__.py file nor FIXTURE_DIRS (fixture folder is a subfolder of app folder, isn't it?).

did you add fixture param in yr test class?

what version of django are you using?

Davide
Reply all
Reply to author
Forward
0 new messages