Django test not loading fixture data

后端 未结 4 1078
面向向阳花
面向向阳花 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 07:10

    One thing to note, when creating the FIXTURE_DIRS constant in your settings file, be sure to leave out the leading '/' if you have a general fixtures directory off of the root of your project.

    Ex:
    '/actual/path/to/my/app/fixtures/'

    Now, in the settings.py file:
    Will NOT work:
    FIXTURE_DIRS = '/fixtures/'

    Will work:
    FIXTURE_DIRS = 'fixtures/'

    It's possible this depends on how your other routes are configured, but it was a gotcha that had me scratching my head for a little while. Hope this is useful. Cheers.

提交回复
热议问题