Django在测试中加载装置(不是来自已安装的应用程序)
是否有方法加载不在appname/fixtures中的装置?根据,fixture必须位于已安装的应用程序目录中只需使用call\u命令以编程方式调用“loaddata”。您可以在安装程序中执行此操作Django在测试中加载装置(不是来自已安装的应用程序),django,unit-testing,testing,fixtures,testcase,Django,Unit Testing,Testing,Fixtures,Testcase,是否有方法加载不在appname/fixtures中的装置?根据,fixture必须位于已安装的应用程序目录中只需使用call\u命令以编程方式调用“loaddata”。您可以在安装程序中执行此操作 from django.test import TestCase from django.core.management import call_command class GlobalSetup(TestCase): def setUp(self): # Manually
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)
您可以使用
FIXTURE\u DIRS
设置定义其他位置以搜索装置: