load_initial_data.py 文件源码

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

项目:bakerydemo 作者: wagtail 项目源码 文件源码
def handle(self, **options):
        fixtures_dir = os.path.join(settings.BASE_DIR, 'base', 'fixtures')
        fixture_file = os.path.join(fixtures_dir, 'bakerydemo.json')

        # Wagtail creates default Site and Page instances during install, but we already have
        # them in the data load. Remove the auto-generated ones.
        if Site.objects.filter(hostname='localhost').exists():
            Site.objects.get(hostname='localhost').delete()
        if Page.objects.filter(title='Welcome to your new Wagtail site!').exists():
            Page.objects.get(title='Welcome to your new Wagtail site!').delete()

        call_command('loaddata', fixture_file, verbosity=0)

        print("Awesome. Your data is loaded! The bakery's doors are almost ready to open...")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号