Fix: issues #57
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Page 'Gemini CLI: The most frustrating agent on the planet?' has been updated.
Page 'Gemini CLI: The most frustrating agent on the planet?' has been updated.
Page 'Gemini CLI: The most frustrating agent on the planet?' has been published. View live Edit
And it ALSO RENDERS ON THE FRONT PUBLIC FACING PAGE:
Page 'Gemini CLI: The most frustrating agent on the planet?' has been updated.
Page 'Gemini CLI: The most frustrating agent on the planet?' has been updated.
Page 'Gemini CLI: The most frustrating agent on the planet?' has been published. View live Edit
It eventually goes away in the admin, but it appears to be permanently printed to the frontend????
And it CONSTANTLY says I saved stuff in another window when I'm not??
Investigation Findings
Investigated all three issues. Here's the root cause analysis and proposed fix for each.
1. Slug requires manual entry
Root cause: The
ArticlePageAdminForm.clean()method callssuper().clean()(Wagtail's ownWagtailAdminPageForm.clean()) before the custom auto-slug logic runs. Wagtail's parentclean()runs its own slug validation/sanitisation first. If the slug is empty at that point, Wagtail may add a form error or handle it in a way that conflicts with the custom auto-generation that runs afterwards.Additionally, the slug field lives in the SEO tab (4th tab, via
SeoMixin.seo_panels) while the title is in the Content tab (1st tab). Wagtail's JavaScript auto-slug generation from the title field may not sync across tabs in theTabbedInterface, so the browser-side auto-slug never fires — the user has to manually navigate to the SEO tab and type a slug.The existing test (
test_article_admin_form_clean_applies_defaults) monkeypatchessuper().clean()entirely, which hides this interaction.Proposed fix: Restructure
clean()so the slug (and other defaults) are populated before callingsuper().clean(). This ensures Wagtail's validation sees a populated slug. For example, overrideclean_slug()or inject defaults intoself.data/cleaned_databefore the parent runs. Also consider moving the slug field to the Metadata tab so it's more discoverable.File:
apps/blog/models.py—ArticlePageAdminForm.clean()(line 224)2. Admin messages rendering on the public frontend
Root cause:
templates/base.htmllines 29–35 render all Django messages framework messages on the public-facing frontend:The
django.contrib.messagescontext processor is active (inconfig/settings/base.pyline 87), making messages available in every template. Wagtail admin operations (save, publish) add success messages to the session. The flow is:base.htmlrenders the messages block → admin messages appear on the public pageSince the session cookie is shared between
/cms/and the public site (same domain), admin messages leak to the frontend. This only affects the admin user's own browser session, not other visitors — but it's still wrong and alarming.Proposed fix: Remove the
{% if messages %}block fromtemplates/base.htmlentirely. Wagtail's admin templates have their own message rendering. If frontend flash messages are needed later (e.g. for newsletter signup confirmation), use a separate mechanism with message tags to filter admin vs. frontend messages.File:
templates/base.htmllines 29–353. False "saved in another window" warnings
Root cause: The
ArticlePage.save()method (line 367) unconditionally mutates fields on every save:read_time_mins(line 377)summaryif empty (line 373–374)published_datefromfirst_published_at(line 375–376)This same auto-generation logic also exists in
ArticlePageAdminForm.clean()(lines 228–238), creating a dual-write pattern where fields can be modified at two different points.In Wagtail 7, the publish workflow involves multiple save operations (save draft → publish). Each
save()call recalculatesread_time_minsand potentially modifies other fields, creating new revisions. Wagtail's edit conflict detection compares the revision loaded in the editor with the current revision — if they differ (because the publish workflow's intermediate save created a new one), it shows the "saved in another window" warning.Proposed fix:
save()for fields already handled byclean()(summary, category defaults). The form is the right place for these.read_time_minswith a change check (only update if the body actually changed).published_dateauto-set insave()since it depends onfirst_published_atwhich is set by Wagtail during publish, but guard it to only run once.File:
apps/blog/models.py—ArticlePage.save()(line 367)Summary
clean()auto-fills slug aftersuper().clean()validates it; JS auto-slug broken across tabsArticlePageAdminForm.clean()base.htmlrenders all Django messages including Wagtail admin onestemplates/base.htmllines 29–35save()mutates fields on every save, causing revision drift during publish workflowArticlePage.save()I can start on the fix branch if you want.