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...

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.

There was also a problem with the encoding. The encoding on the file was UTF-16, not UTF-8. It was converted using Notepad++

  1. rename categories.js to categories.json
  2. run python manage.py loaddata fixtures/goods/categories.json
Back to Top