def get_yaml_for_all_models(self, schema):
models = django.apps.apps.get_models()
ct = 0
self.stdout.write(" ")
self.stdout.write("Create .yaml for these models in schema " + str(schema) + " :")
self.stdout.write(" ")
for model in models:
self.stdout.write(model._meta.db_table)
if schema != 'public':
data = serializers.serialize("yaml", model.objects.all())
dir = BASE_DIR + "/crm/fixtures/yamlsrc/" + str(schema)+'__'+model._meta.model_name + ".yaml"
ct += 1
with open(dir, "w") as out:
print(data, end="", file=out)
self.stdout.write(" ")
self.stdout.write("Number of created .yaml for schema "+str(schema)+" are " + str(ct))
self.total_yaml_created+=ct
评论列表
文章目录