Open andreasnuesslein opened 8 years ago
Hi @nutztherookie! Thanks a lot for the feedback :)
I'd certainly love to see something that replicated Django ModelAdmin's 'actions' in the future, but there are no set plans to tackle that right away. I guess we have some thinking/decision-making to do, in regards to how this app evolves and becomes more integrated into the wagtail core (and what things in core need to also change, in order for that to happen)
When modeladmin
was still in it's infancy (as wagtailmodeladmin), I made an attempt to add an 'actions-like' feature. But at the time, I stumbled when it came to handling permissions, and ensuring only users with the right actions could perform them. I think it was particularly complicated because of the way pages have their own tree-based permission system, and I decided it was a little too complicated to tackle on my own. Hopefully now, with a keen group of wagtail contributors behind it, that's something that might be overcome.
Hey @ababic, thank you for your elaborate answer =)
I know little of wagtails permissions-setup; but also I don't really need it for my project. I'm gonna start hacking 'actions' into wagtail and I'll see where it leads me. If it turns out to be somewhat mature I'll try and upstream it :)
But, if we'll have this features, django-admin
will be 'deprecated'. So, for now we can used django-admin
normally.
@salahAdDin I'm afraid I'm struggling to understand what you mean there. Are you suggesting that this feature should or shouldn't be implemented? What do you mean when you say django admin will be 'deprecated'? I'm pretty sure django admin isn't going anywhere. It's a fundamental part of django.
Ok, i say, for our use, with wagtail-admin
and model-admin
, for us, will be deprecated because, for what have django-admin
if wagtail-admin
do all?
Sorry @SalahAdDin, I don't know what you're asking. Nobody is planning to make any changes that would prevent you running django-admin and wagtailadmin for the same project if you wanted to. Having a feature like this would obviously give developers less need to do that though, which can only be a good thing.
Hi @nutztherookie did you get anywhere with 'actions'? A few other people have asked about this recently.
hey @tomdyson, no sorry - i got derailed and ended up working on other things of the project.
i'd still like to work on it, but don't know when that might be.
Any moves forward on this? I need this one too.
Just pinging this forward - has there been any implementation of this for Wagtail yet? It can be done in the standard django-admin, so not the end of the world, but it would be really nice to have the option in Wagtail as well.
Re-visiting this in 2021. Would love such a feature, with the option to define actions in a subclass of ModelAdmin class, and apply those to multiple instances.
Having the ability to perform mass actions on multiple instances would make things so much easier. Would love an update on this.
Now that bulk actions exist as of 2.15 I will rename this to be add bulk actions to ModelAdmin
@alittle-ninja there are no plans in place for this on the core roadmap at this time but anyone is welcome to prepare are PR for this feature.
On the topic of new features for modeladmin, I think we need to be careful how we tread, as there are rough plans to sunset that module completely (I'd hate for someone to go to all the effort of contributing and polishing, only for the work never to be merged).
The plan isn't entirely clear, but from the conversations I've had with @laymonage, it looks something like this:
@laymonage please do let me know if this summary is inaccurate. It's been a while since we discussed this!
The summary posted by @ababic above is accurate.
In regards to bulk actions, I think it could use some refactoring internally before we start expanding it, as the approach is not ideal in some places, e.g. how the strings are set up for the client-side interface: https://github.com/wagtail/wagtail/blob/a6a91e1a014912c6f7f65cc367c099e9338c8906/wagtail/admin/localization.py#L58-L95
Anyway, as per wagtail/rfcs#85, I'm transferring this issue over to the wagtail-modeladmin repo.
https://docs.wagtail.org/en/stable/extending/custom_bulk_actions.html#custom-bulk-actions
docs for how to get it working in wagtail for lost souls
I recently explored implementing bulk actions within a ModelViewSet and achieved this functionality in this commit https://github.com/Morsey187/wagtail-defender/commit/a24e346f0863e345c6c470c0b9870fb8d2dbb2f0.
Although this approach might become incompatible with future releases due to bulk actions potentially being refactored as mentioned in the previous comments, it does currently function well and doesn't require overriding too much code. So thought I'd share incase it's helpful to anyone looking for a similar approach with Wagtail 5.2 and are migrating from ModelAdmin to ModelViewset.
I recently explored implementing bulk actions within a ModelViewSet and achieved this functionality in this commit https://github.com/Morsey187/wagtail-defender/commit/a24e346f0863e345c6c470c0b9870fb8d2dbb2f0.
Screenshot
Thanks @Morsey187, that is very helpful! I'm glad that it is possible to integrate bulk actions with ModelViewSet.
I think the only bit I can definitely say for the moment is that the get_columns
method will be removed in favour of making the columns
a cached property: https://github.com/wagtail/wagtail/commit/a2b5baee83c1510268a6c3915ab075adf4be8365
I think the same can be done in your custom code. Or, alternatively I think it's possible to use list_display
to achieve this, e.g.
class MyModelViewSet(ModelViewSet)
list_display = [BulkActionsCheckboxColumn("bulk_actions"),
*ModelViewSet.index_view_class.columns]
Which would eliminate the need to override the index view class.
Although this approach might become incompatible with future releases due to bulk actions potentially being refactored as mentioned in the previous comments, it does currently function well and doesn't require overriding too much code. So thought I'd share incase it's helpful to anyone looking for a similar approach with Wagtail 5.2 and are migrating from ModelAdmin to ModelViewset.
Yeah the bulk actions system is kind of like its own thing at the moment. Not quite sure what kind of refactoring will be done to it, though it's likely we won't be doing anything drastic in the near future as that would likely break existing setups.
Thank you again for sharing your work! I think we might be able to make this built-in to ModelViewSet in the future, which would also minimise the gap between it and SnippetViewSet.
Thanks @laymonage, Let me know if I can help with that, I'll follow up with anything in that new issue thread you created.
Just to note:
I think the same can be done in your custom code. Or, alternatively I think it's possible to use list_display to achieve this, e.g.
I think there was an issue with using list_display, as you'll still need to update the IndexView's get_columns method to handle the bulk actions column along with the title field (_get_title_column()
).
Hey Torchies,
we are trying your new ModelAdmin-feature and realized there is no "I'm selecting a bunch of objects and I'm gonna < delete/export/dosomething > them all". Django Admin:
So we were wondering: Are you planning on implementing this? If so, do you know when that might be the case? :)
Thanks a bunch
PS: Great job on the ModelAdmin and Wagtail in general