2
0
Эх сурвалжийг харах

Data loader removes auto-generated Site and Page

Scot Hacker 8 жил өмнө
parent
commit
f5a86c29a9

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 5 - 33
bakerydemo/base/fixtures/bakerydemo.json


+ 6 - 3
bakerydemo/base/management/commands/load_initial_data.py

@@ -4,7 +4,8 @@ from django.conf import settings
 from django.core.management.base import BaseCommand
 from django.core.management.base import BaseCommand
 from django.core.management import call_command
 from django.core.management import call_command
 
 
-from wagtail.wagtailcore.models import Site
+from wagtail.wagtailcore.models import Site, Page
+
 
 
 class Command(BaseCommand):
 class Command(BaseCommand):
     def handle(self, **options):
     def handle(self, **options):
@@ -13,9 +14,11 @@ class Command(BaseCommand):
 
 
         call_command('loaddata', fixture_file, verbosity=0)
         call_command('loaddata', fixture_file, verbosity=0)
 
 
-        # Wagtail creates a Site instance during initial load, but we already have
-        # one in the data load. Both point to the same root document, so remove the auto-generated one.
+        # 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():
         if Site.objects.filter(hostname='localhost').exists():
             Site.objects.get(hostname='localhost').delete()
             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()
 
 
         print("Awesome. Your data is loaded! The bakery's doors are almost ready to open...")
         print("Awesome. Your data is loaded! The bakery's doors are almost ready to open...")

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно