question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Page.search_panels and Page.content_panels are too restrictive about how they can be appended to

See original GitHub issue

As 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:closed
  • Created 8 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
gasmancommented, May 10, 2016

@SalahAdDin Yes - that’s because the fix has not been released yet. It’ll be in Wagtail 1.5.

0reactions
SalahAdDincommented, May 10, 2016

Well, but, for now, using in these way give me a bug:

  File "/run/media/salahaddin/Datos/Proyectos/Trabajo/uzman/uzman/core/models.py", line 192, in <module>
    class HomePage(Page):
  File "/run/media/salahaddin/Datos/Proyectos/Trabajo/uzman/uzman/core/models.py", line 196, in HomePage
    index.SearchField('body')
TypeError: can only concatenate tuple (not "list") to tuple
Read more comments on GitHub >

github_iconTop Results From Across the Web

Page models — Wagtail Documentation 4.1.1 documentation
Each page type (a.k.a. content type) in Wagtail is represented by a Django model. All page models must inherit from the wagtail.models.Page class....
Read more >
Adding content with blocks - Squarespace Help Center
Blocks are drag-and-drop features that display content on your site. You'll use them to customize your pages with a variety of content, ...
Read more >
Add or remove page restrictions | Confluence Cloud
Set view and edit restrictions on a page you're not ready to share with everyone, or one that contains sensitive information in Confluence...
Read more >
Panels and Page Manager in Drupal 8 - Pantheon.io
Panels & page manager give Drupal administrators the ability to create ... API in core) so you can, for example, display a field...
Read more >
Wagtail Pages - consumerfinance.gov - CFPB
Editor panels define how the page's fields and StreamFields will be organized for content editors; they correspond to the tabs that appear across...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found