Merge pull request 'fix: update ALL site records in seed, not just is_default_site' (#9) from fix/seed-default-site into main

Reviewed-on: #9
This commit was merged in pull request #9.
This commit is contained in:
2026-02-28 20:42:24 +00:00

View File

@@ -116,17 +116,16 @@ class Command(BaseCommand):
legal_index.add_child(instance=privacy)
privacy.save_revision().publish()
# Update the existing default site (whatever hostname Wagtail created it with)
# rather than creating a new 127.0.0.1 entry that leaves localhost pointing
# to the Welcome page.
site = Site.objects.filter(is_default_site=True).first()
# Point every existing Site at the real home page and mark exactly one
# as the default. Wagtail's initial migration creates a localhost:80
# site that matches incoming requests by hostname before the
# 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:
site = Site(hostname="localhost", port=80)
site.root_page = home
site.is_default_site = True
site.site_name = "No Hype AI"
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."))