2012-01-17 16 views

回答

1

只需使用call_command以編程方式調用'loaddata'。你可以在setUp中做到這一點。

from django.test import TestCase 
from django.core.management import call_command 

class GlobalSetup(TestCase): 
    def setUp(self): 
     # Manually calling loaddata to import fixures 
     # that are not in INSTALLED_APPS 
     call_command('loaddata', 'cur_dir/fixtures_name', verbosity=0) 
相關問題