Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dumpdata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./manage.py dumpdata --format yaml -e auth.user -e wagtailcore.revision -e wagtailcore.referenceindex -e wagtailsearch.indexentry -e newsletter.newsletteremailaddress -e images.wagtailiorendition -e wagtailsearchpromotions.query -e wagtailsearchpromotions.querydailyhits -e wagtailcore.pagelogentry -e sessions.session -e packages.package -e packages.grid -e wagtailredirects.redirect -e wagtailcore.pagesubscription -e wagtailcore.pageviewrestriction -e wagtailcore.grouppagepermission -e wagtailcore.modellogentry > wagtailio/core/fixtures/initial_data.yaml
Empty file.
Empty file.
22 changes: 22 additions & 0 deletions wagtailio/core/management/commands/load_initial_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django.contrib.auth.models import Group, Permission
from django.contrib.contenttypes.models import ContentType
from django.core.management import call_command
from django.core.management.base import BaseCommand
from django.db import transaction

from wagtail.models import Page, Site


class Command(BaseCommand):
help = "Load initial data for the Wagtail.org project"

@transaction.atomic
def handle(self, *args, **options):
Site.objects.all().delete()
Page.objects.all().delete()
Permission.objects.all().delete()
Group.objects.all().delete()
ContentType.objects.all().delete()

Comment on lines +19 to +20
Copy link

Copilot AI Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting all ContentType objects may remove essential system metadata that Django uses for content type management, potentially causing downstream issues. Consider targeting only specific ContentType objects that need to be reset or ensure a mechanism to properly regenerate them.

Suggested change
ContentType.objects.all().delete()
ContentType.objects.filter(model__in=['page', 'site', 'permission', 'group']).delete()

Copilot uses AI. Check for mistakes.
call_command("loaddata", "initial_data")
self.stdout.write(self.style.SUCCESS("Successfully loaded initial data"))