[Solved]-Django shell: Command to load test fixture data?

14👍

ilardm’s answer points in the right direction, specifically what you want is:

from django.core.management import call_command
call_command('loaddata', 'fixture_name.json')

Edit: But the correct way to include fixtures in test cases is like this:

class TestThis(TestCase):
    fixtures = ['myfixture.json']

    def setUp(self):
        # Ready to test
👤oldsea

5👍

I expect ./manage.py loaddata fixture_name.json is what you want.

1👍

👤ilardm

Leave a comment