wagtail / wagtail-generic-chooser

A toolkit for custom chooser popups in Wagtail
BSD 3-Clause "New" or "Revised" License
116 stars 25 forks source link

Override save method on create #57

Closed joahim closed 2 years ago

joahim commented 2 years ago

Is there an easy way to override the save method when creating objects within the chooser? Similar to Django admin's save_model mechanism.

In my case, I would need to set the current user (from request) on the object being created.

gasman commented 2 years ago

This can be done by overriding the form_valid method:

https://github.com/wagtail/wagtail-generic-chooser/blob/7d26029dd10d0a1e1f67fb39f0a9a768df47bce0/generic_chooser/views.py#L457-L462