Customizing table columns for admin lists

890 views
Skip to first unread message

Michael Godshall

unread,
Aug 29, 2014, 3:41:56 PM8/29/14
to wag...@googlegroups.com
I have two custom Page models called BlogPage and BlogPageIndex.  BlogPageIndex is the parent page many BlogPages.  By default, the BlogPageIndex admin page shows a list of BlogPages with the following columns: Title, Type, Status.  I would like to add more columns to this page with fields that are unique to the BlogPage model.  Can you recommend the best approach for accomplishing this?  Thanks!

Joss Ingram

unread,
Aug 30, 2014, 7:43:49 AM8/30/14
to wag...@googlegroups.com
hi

It seems like you're asking how to add more fields to your blog page model but if you've made a custom blog page model then presumably you know how to do this? Are you asking how to display more fields in your blog index from the blog page model?

I think you may get more help if you provide some code for what you have now and clarify what you're looking to do? Maybe.

I'm no expert but will give it a go if you clarify your question a bit :)

Joss

Michael Godshall

unread,
Sep 2, 2014, 10:52:58 AM9/2/14
to wag...@googlegroups.com
Hi Joss,

I am asking how to display more fields in my blog index from the blog page model.  Here's an image of the page I am referring to.


As you can see in the image, it displays the Title, Type, and Status fields by default.  I would like to add other fields from the BlogPage model to this display.  Is there a way to control this in the python code, or do I have to override the admin template directly (wagtailadmin/pages/list.html)?

Joss Ingram

unread,
Sep 2, 2014, 11:45:27 AM9/2/14
to wag...@googlegroups.com
Ah, in the admin, i see. I think you'll need to over ride the wagtail admin yes. I've never done that, and never intend to tbh,

Michael Godshall

unread,
Sep 2, 2014, 11:47:16 AM9/2/14
to wag...@googlegroups.com
Thanks for the update.  I was hoping it was customizable like the Django admin list_display.

Matthew Westcott

unread,
Sep 2, 2014, 11:50:15 AM9/2/14
to wag...@googlegroups.com
Hi Michael,
Customising the set of columns isn't something we considered when implementing that listing page, I'm afraid - I suspect it'll need some fairly large-scale hacking on Wagtail core to make it work. A large part of the difficulty comes from the fact that Wagtail doesn't formally 'know' that all the children of BlogIndex are of type BlogPage, so the objects that it's looping over are plain Page models, which don't have access to the additional fields of BlogPage. (Or rather, not without an extra database query - and we'd certainly want to avoid hitting the database for each row in the listing.) It might be possible to do something based on the subpage_types setting of BlogIndex, but then we're heading down the path of creating new semantics for subpage_types, and having to think about how that interacts with the rest of Wagtail.

Cheers,
- Matt

On 2 Sep 2014, at 15:52, Michael Godshall <michael...@gmail.com> wrote:

> Hi Joss,
>
> I am asking how to display more fields in my blog index from the blog page model. Here's an image of the page I am referring to.
>
>
>
>

Tim Heap

unread,
Sep 3, 2014, 7:59:02 PM9/3/14
to wag...@googlegroups.com
I also came across this issue, and some other related ones, regarding the very generic nature of the Page admin when confronted with a blog / news set up. The solution I ended up going with was to create a standalone wagtail plugin for news. It allows developers to designate specific Page models as a news index that has news items published underneath them. News items are *not* pages. A separate section in the administraiton area allows users to add news items to any news indexes in the site. This separation allowed the news section to order news items by date, display extra columns, and other things not possible when working with pages.

The package is named `wagtailnews` on PyPI, and can be found at https://pypi.python.org/pypi/wagtailnews. Documentation is sparse at this point, but there should be enough to get a simple blog up and running.


--
You received this message because you are subscribed to the Google Groups "Wagtail" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wagtail+u...@googlegroups.com.
To post to this group, send an email to wag...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/wagtail/9E61BB3C-FDFF-4DB2-8129-C68F2F89C060%40torchbox.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages