Django test not loading fixture data

后端 未结 4 1079
面向向阳花
面向向阳花 2021-02-07 06:40

I have written tests for a Django project that i am working on, but one particular fixture fails to load. The fixture is generated using dumpdata and i havent fiddled with it at

4条回答
  •  甜味超标
    2021-02-07 06:49

    I Am not sure if this fixes your problem, but on this site:

    https://code.djangoproject.com/wiki/Fixtures

    I found an interesting remark:

    you see that Django searches for appnames/fixtures and settings.FIXTURE_DIRS and loads the first match. So if you use names like testdata.json for your fixtures you must make sure that no other active application uses a fixture with the same name. If not, you can never be sure what fixtures you actually load. Therefore it is suggested that you prefix your fixtures with the application names, e.g. myapp/fixtures/myapp_testdata.json .

    Applying this (renaming the fixtures with appname as prefix in the filename), solved my problem (I had the same issue as described here)

提交回复
热议问题