fix: update ALL site records in seed, not just is_default_site #9

Merged
mark merged 1 commits from fix/seed-default-site into main 2026-02-28 20:42:25 +00:00
Showing only changes of commit 08e003e165 - Show all commits

View File

@@ -116,17 +116,16 @@ class Command(BaseCommand):
legal_index.add_child(instance=privacy) legal_index.add_child(instance=privacy)
privacy.save_revision().publish() privacy.save_revision().publish()
# Update the existing default site (whatever hostname Wagtail created it with) # Point every existing Site at the real home page and mark exactly one
# rather than creating a new 127.0.0.1 entry that leaves localhost pointing # as the default. Wagtail's initial migration creates a localhost:80
# to the Welcome page. # site that matches incoming requests by hostname before the
site = Site.objects.filter(is_default_site=True).first() # is_default_site fallback is ever reached, so we must update *all*
# sites, not just the is_default_site one.
Site.objects.all().update(root_page=home, site_name="No Hype AI", is_default_site=False)
site = Site.objects.first()
if site is None: if site is None:
site = Site(hostname="localhost", port=80) site = Site(hostname="localhost", port=80)
site.root_page = home
site.is_default_site = True site.is_default_site = True
site.site_name = "No Hype AI"
site.save() site.save()
# Remove any other conflicting default-site entries left by test fixtures
Site.objects.exclude(pk=site.pk).filter(is_default_site=True).update(is_default_site=False)
self.stdout.write(self.style.SUCCESS("Seeded E2E content.")) self.stdout.write(self.style.SUCCESS("Seeded E2E content."))