def load_fixture(cls, fixture_spec, apps, schema_editor):
app_name, model_name, fixture_file_name = fixture_spec
original_apps = serializers.python.apps
serializers.python.apps = apps
queryset = cls.get_model_class(app_name, model_name,
apps, schema_editor)
path, fixture_type = cls.fixture_path(app_name, fixture_file_name)
fixture_file = open(path)
objects = serializers.deserialize(fixture_type,
fixture_file,
ignorenonexistent=True)
for obj in objects:
cls.update_or_create_object(obj, queryset)
fixture_file.close()
serializers.python.apps = original_apps
评论列表
文章目录