getyaml.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:djangoCRM2 作者: poiskpoisk 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号