Closed puredriver closed 2 years ago
Hi Andre, thank you for your report :)
Its quite hard to tell what actually causes the fault but I'll try to give you some background information:
The ImageGalleryMixin
enables the usage of blocks.GalleryBlock
in wagtail pages.
The GalleryBlock
hooks in instances of Album
class into the page iff GalleryBlock.collection
matches Album.collection
.
The Album
class is realized using django-modelcluster (it inherits from ClusterableModel
).
From my experience, even though it is super useful, django-modelcluster can lead to pretty strange errors if the database is not as it should be. E.g. if you did not do all migrations etc.
So to come back to your problem: There are not so many possible causes (as the collection attribute just occurs twice), as the collection does not occur that often. Before you are digging into it further I would suggest that you check if the migrations were applied correctly
Thx for your quick answer! I tried it again with a fresh wagtail installation...described here: https://docs.wagtail.io/en/stable/getting_started/tutorial.html (until the admin is accessible) and your instructions in the README. Migrations were successfully done.
HomePage Model
class HomePage(ImageGalleryMixin, Page):
content = StreamField([
#...
("gallery", GalleryBlock()),
#...
], blank=True)
# content panel for the CMS (same as always)
content_panels = Page.content_panels + [
StreamFieldPanel("content"),
]
Django 3.2.10 Wagtail 2.15.1
Unfortunatly same result see screenshot
Hi again, I was able track down the error and it is actually related to wagtail>=2.13.
The last version I've tested was wagtail 2.12, sorry for that.
I just started a fresh wagtail demo like you did to reproduce the mistake. It turned out that the collection attribute is stored correctly and is read out correctly, but the attribute is not available to the AdminChooser.render_html()
.
After quite some research I found out that wagtail started to use some javascript rendering called telepath.
The problem was that for wagtail > 2.12 every class inheriting from ChooserBlock
(from the extention wagtail-generic-chooser needs to implement a get_form_state()
function. The GalleryBlock
is StructBlock
that contains such an affected block CollectionChooserBlock
.
To fix the problem CollectionChooserBlock
(in blocks.py) needs to be extended by the following code:
def get_form_state(self, value):
return self.widget.get_value_data(value)
I will update this package to fix this bug.
I've updated the pypi package by upgrading wagtail-photo-gallery to version 0.0.2 the error should be resolved.
pip install wagtail-photo-gallery -U
Many thanks for this quick fix Jonas! I gonna close this issue. Merry Christmas!
Hi Jonas, the wagtail admin does not store the collection value. I can select a collection but when i press "save draft" of the page the collection value is empty
Wagtail 2.15.1 Any ideas...thx Andre