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


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


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



Leave a comment