# SPDX-FileCopyrightText: 2024 Thomas Breitner <t.breitner@csl.mpg.de>
#
# SPDX-License-Identifier: EUPL-1.2
import os
from django.conf import settings
from django.core.management.base import BaseCommand
from django.core.management import call_command
from wagtail.models import Site, Page
[docs]
class Command(BaseCommand):
[docs]
def handle(self, *args, **options):
fixtures_dir = os.path.join(settings.BASE_DIR, "core", "fixtures")
fixture_file = os.path.join(fixtures_dir, "eucrim_initial_data.json")
print("fixture_file: {}".format(fixture_file))
# 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=2)