Search code examples
djangopostgresql

Fixtures are not loaded and says they are not found, although they are there


In Django I have folder with fixtures\goods\categories.js and fixtures\goods\products.js. I installed PostgreSQL and I have tables categories and products. But when I write python manage.py loaddata fixtures/goods/categories.json I get the error: CommandError: No fixture named 'categories' found.

How do I load fixtures? This may be due to the fact that I may have previously loaded everything into something other than the environment. That is, I did python manage.py dumpdata not in the environment...


Solution

  • As @AKX says in their comment, you you use .json files, not .js. JSON is a (very) strict subset of JavaScript that only allows to write data objects, no loops, variables, conditions, etc. .js would imply you have a JavaScript file.

    This is also what the Django error says, it can not find categories.json, not categories.js.