fix: update ALL site records in seed, not just is_default_site
Wagtail's initial migration creates a localhost:80 site. Wagtail matches incoming requests by hostname before ever checking is_default_site, so updating only the is_default_site record left localhost:80 still pointing at the Welcome page. Fix by updating root_page on every site. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -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."))
|
||||||
|
|||||||
Reference in New Issue
Block a user