bakerydemo icon indicating copy to clipboard operation
bakerydemo copied to clipboard

Error attempting to publish edits of gallery page

Open JoanEliot opened this issue 4 years ago • 2 comments
trafficstars

I'm new to Wagtail and pretty new to Django but the bakery demo is already running fine here (on Windows 10, with a conda as my virtual environment).

My problem: In Wagtail admin, just getting my feet wet by seeing what happens when I change things a little, I'm unable to publish the included Gallery page or new Gallery pages unless I add content in the Page Body section. If, for example, I change the Title text from "Gallery" to "Showcase" and then click Publish, I get a red bar at the top announcing validation errors and a "This field is required" error in the Page Body area. (Sorry, I haven't yet learned the term for page sections accessible in Admin, such as Title, Page Body, etc.)

I note that the template gallery_page.html doesn't reference the page.body [insert term here]; therefore when content is added to the Page Body section and the page is then successfully published, that content is not displayed.

Please help me understand this behavior and let me know how I can modify/create Gallery pages without adding content in Page Body.

image

JoanEliot avatar Nov 28 '20 18:11 JoanEliot

@JoanEliot you need to add at least one block for the "page body" field. Or, change https://github.com/wagtail/bakerydemo/blob/master/bakerydemo/base/models.py#L311 to have BaseStreamBlock(required=False), may need a new migrations (in the VM or virtual environment: python3 manage.py makemigrations, then python3 manage.py migrate if it generated a new migration)

Do join the Wagtail community Slack - https://github.com/wagtail/wagtail/wiki/Slack, there is a #support channel for this type of questions and more!

zerolab avatar Nov 30 '20 09:11 zerolab

It sounds like the default content in the demo doesn't pass the demo's own validation, which I'd count as a legitimate bug.

gasman avatar Nov 30 '20 10:11 gasman

This was fixed in Wagtail 2.13 - the blank=True on the StreamField definition is now sufficient to make an empty stream valid, which was presumably the intention all along - it's no longer necessary to set required=False on the block definition too.

https://docs.wagtail.org/en/stable/releases/2.13.html#updated-handling-of-non-required-streamfields

Have confirmed that all pages on a fresh bakerydemo build now validate successfully on 'save draft'.

gasman avatar Aug 25 '22 16:08 gasman