Преглед изворни кода

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

Разлика између датотеке није приказан због своје велике величине
+ 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

Неке датотеке нису приказане због велике количине промена