Page.search_panels and Page.content_panels are too restrictive about how they can be appended to
See original GitHub issueAs I just discovered while trying to standardize my model code, Page.search_panels
only allows tuples to be appended to it, while Page.content_panels
only allows lists. Both really should allow any iterable, or at the very least accept a common type of iterable. Attempting to append a tuple onto content_panels
gives TypeError: can only concatenate list (not "tuple") to list
, while attempting to append a list onto search_panels
gives TypeError: can only concatenate tuple (not "list") to tuple
.
As it stands right now, extensions to these two attributes on custom models have to look exactly like this:
class StaticPage(Page):
body = StreamField([
('heading', blocks.CharBlock(classname="full title")),
('paragraph', blocks.RichTextBlock()),
('assets', CarouselBlock()),
])
image = models.ForeignKey('CustomImage', null=True, blank=True, on_delete=models.SET_NULL,
related_name='+'
)
content_panels = Page.content_panels + [
StreamFieldPanel('body'),
ImageChooserPanel('image'),
]
search_fields = Page.search_fields + (
index.SearchField('body'),
)
Which is frustrating for developers who’d prefer to use a single type of iterable throughout.
There may be alternate ways to bring is the base values of these attributes from Page
, but I don’t know them off hand, and the Wagtail docs don’t mention them.
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
@SalahAdDin Yes - that’s because the fix has not been released yet. It’ll be in Wagtail 1.5.
Well, but, for now, using in these way give me a bug: