Django: How to override a related sets "add" method?

Posted by MB_ on Stack Overflow See other posts from Stack Overflow or by MB_
Published on 2010-05-21T10:46:21Z Indexed on 2010/05/21 11:20 UTC
Read the original article Hit count: 184

Filed under:
|
|

I am working on a django project and i want to send a signal when something get's added to some models related set, e.g. we have an owner wo has a set of collectables and each time the method owner.collectable_set.add(something) is getting called i want signal like "collectable_added" or something. signals are clear to me, but in which manager(?) the "add" method sits that i want to override is unclear to me.

edit: Upon the request of Xaver to provide more details. You can easily override a models "save" method, by simply defining it and calling the super-"save" so it get's properly saved with some extra functionality for example. But i wonder where to override a related sets "add" method.

gosh, i think i haven't brought in any further details. but i think it even should be clear what i want to do from the first paragraph.

edit2: This is the method i want to override. Is it recommended to do so or do you suggest another way to place the sending of the signal?

© Stack Overflow or respective owner

Related posts about django

Related posts about related