CommandError: No fixture named 'myapp' found

Viewed 8075

I created a json file myapp/fixtures/initial_data.json , which has the data to be loaded.

But when I run

python manage.py loaddata myapp

Getting below error

CommandError: No fixture named 'myapp' found.

What could be reason for the error?

9 Answers

You should write the Full Path Of the code Like python manage.py loaddata my_app/data/__init.json Its Should will be work.

Make sure you are running the command from the right directory. For me, simply moving to the right directory fixed this issue.

Good luck

Try python manage.py loaddata 'myapp' instead of python manage.py loaddata myapp. It should work. Make sure you are in the right directory (a.k.a. the directory where manage.py is).

Experienced this error and tried the solutions mentioned above but it didn't work. What had happened was that I was on the wrong branch. You can check to ensure that you're doing the python manage.py loaddata --myapp file.json on the correct branch that has the file.

None of these solutions worked. I needed to add ".json" to the end of the file name. Then python manage.py loaddata my_data.json worked.

Need to check your directory now. If your directory are located at apps like this C:\Users\XXX\myapp> then python manage.py loaddata fixtures/initial_data.json

NOTE : If you have done any changes in the myapp you have to do python manage.py makemigrations and python manage.py migrate first before you loaddata.

You can try python manage.py loaddata */fixtures/*.json this will load all your fixtures from all applications. (if there are any).

Related