瀏覽代碼

Fix dump data export path, data loadable by both sqlite and postgres
- Includes dump_data recipe in readme for future use

Scot Hacker 8 年之前
父節點
當前提交
dc5a672460
共有 3 個文件被更改,包括 38 次插入7 次删除
  1. 30 6
      bakerydemo/base/fixtures/bakerydemo.json
  2. 7 0
      bakerydemo/base/management/commands/load_initial_data.py
  3. 1 1
      readme.md

文件差異過大導致無法顯示
+ 30 - 6
bakerydemo/base/fixtures/bakerydemo.json


+ 7 - 0
bakerydemo/base/management/commands/load_initial_data.py

@@ -4,6 +4,7 @@ from django.conf import settings
 from django.core.management.base import BaseCommand
 from django.core.management import call_command
 
+from wagtail.wagtailcore.models import Site
 
 class Command(BaseCommand):
     def handle(self, **options):
@@ -11,4 +12,10 @@ class Command(BaseCommand):
         fixture_file = os.path.join(fixtures_dir, 'bakerydemo.json')
 
         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.
+        if Site.objects.filter(hostname='localhost').exists():
+            Site.objects.get(hostname='localhost').delete()
+
         print("Awesome. Your data is loaded! The bakery's doors are almost ready to open...")

+ 1 - 1
readme.md

@@ -189,6 +189,6 @@ followed by `delete from wagtailimages_rendition;`
 
 To generate new fixtures, run:
 
-`./manage.py dumpdata --natural-foreign --indent 2 -e auth.permission -e contenttypes -e wagtailcore.GroupCollectionPermission -e wagtailimages.filter -e wagtailcore.pagerevision -e wagtailimage.rendition -e sessions > bakerydemo/base/fixtures/bakerydemo.json`
+`./manage.py dumpdata --natural-foreign --indent 2 -e auth.permission -e contenttypes -e wagtailcore.GroupCollectionPermission -e wagtailimages.filter -e wagtailcore.pagerevision -e wagtailimages.rendition  -e sessions > bakerydemo/base/fixtures/bakerydemo.json`
 
 Make a pull request to https://github.com/wagtail/bakerydemo

部分文件因文件數量過多而無法顯示