Django loading fixtures (not from installed apps) in tests
Is there a way to load fixtures that do NOT reside in appname/fixtures? According to django docs, fixtures have to be in directory of INSTALLED_APPS
您可以使用FIXTURE_DIRS
设置来定义其他位置以搜索灯具:https: FIXTURE_DIRS
: FIXTURE_DIRS
Just had to programmatically call 'loaddata' using call_command. You can do it in 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)
链接地址: http://www.djcxy.com/p/52304.html