I have a fairly simple django model in a Wagtail CMS; essentially:
from django.db import models
class Thingy(models.Model):
name = models.CharField(max_length=255, blank=False, null=False, unique=True)
# Many other fields.
panels = [
FieldPanel("name"),
# ...
]
I need to perform an action when this model is saved via the Wagtail model edit form (eg /admin/section/thingy/123/edit
).
Currently, I have registered a post_save signal, however this has resulted in the method being called when the model is saved programmatically (via an import sync task).
I've had a look in the Django docs, but can't see anything obvious... is there a way to register a signal for the form submission (ideally after the internal submission and save is handled).
(If it's any relevance; I need to trigger a search reindex based on a relation to the model; anything that references instance 123 of thing Things that was saved needs to be reindexed)
CodePudding user response:
If you are using ModelAdmin, you can customize your edit view and put your reindexing code in there.