views:

77

answers:

2

I have a situation where I want to offload an xml fragment (an atom event) each time a model instance is saved, updated or deleted. The fragment needs to include information about related objects.

I can't find an event that lets me use information from related objects after saving my object. The post_save signal seems o be triggered before related object have been saved.

Currently I am overriding the ModelAdmin save_model method to output a complete atom entry containing details about the instance and its related objects. But this will only work as long as instances are managed via the admin interface and not when instances are updated programmatically.

Anyone who has managed to create something similar to a post_save_of_everything signal?

A: 

I would imagine that you could add your own save method to your model that calls the base class save method and then creates your atom feed.

Tom Leys
That won't have access to the related objects unfortunately.
PeterK
Why not? It has access to the instance being saved, and that links to its related objects in the normal way, surely?
Daniel Roseman
ManyToMany properties are blank in the model instance save() method, even after super save has been called. They are apparently saved later.
PeterK
Apparently something is cooking for Django 1.2: http://code.djangoproject.com/ticket/5390
PeterK
A: 

Does the atom entry need to be updated only once per instance save? If not, couldn't you just listen to post_save on the related objects?

Greg