wagtail / wagtail

A Django content management system focused on flexibility and user experience

Home Page:https://wagtail.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support Column objects on list_export for SnippetViewSet

cyface opened this issue · comments

Is your proposal related to a problem?

Currently, for situations where we need to use a wagtail.admin.ui.tables.Column object in the list_display property of a SnippetViewSet, we often need to use that same Column in the list_export.

But today SnippetViewSets don't support Column objects in list_export, only in list_display. So we are unable to make the export match the display.

Describe the solution you'd like

Support using wagtail.admin.ui.tables.Column objects in list_export for SnippetViewSets.

Describe alternatives you've considered

  • Custom list_export handler class.
  • Monkey patching

Additional context

Today in a SnippetViewSet for Tags, if we want to include things like number of pages and images that use that tag, we have a Column class that does that calculation. We used to have a method directly on the ModelViewSet, but that stopped working when we converted to SnippetViewSets. So now we use a pair of Column objects to handle those calculations.

On a typical Model, you could just add the methods to the Model itself, but we don't control the Tag model, since it's owned by taggit. Hence why we originally had the methods on the ModelViewSet, and now in Column objects.

Hey @cyface , can you take a look at abdlrhman08/wagtail@a43cf6b and 370cfdf. Let me know if they give you the correct values and proper output.