On Oct 2, 10:46 am, Ant <[EMAIL PROTECTED]> wrote:
> Going with the multi-table inheritance example from the docs:
>
> class Place(models.Model):
>     name = models.CharField(max_length=50)
>     address = models.CharField(max_length=80)
>
> class Restaurant(Place):
>     serves_hot_dogs = models.BooleanField()
>     serves_pizza = models.BooleanField()
>
> I was hoping I could have some external app register a post_save
> signal to a Place. i.e.
>
> post_save.connect(my_callback_function, sender=Place)
>
> and have this trigged by saving any model derived from Place, such as
> a Restaurant. However from my simple test it looks as though I have to
> register a signal for each derived model. i.e
>
> post_save.connect(my_callback_function, sender=Place)
> post_save.connect(my_callback_function, sender=Restaurant)
>
> So I guess I'm just asking if that's expected really. It kinda
> scuppers my loose coupling plans a bit as my external app wouldn't
> know about each and every derived model.
>
> Thanks in advance for any help!

You could register a signal handler that listens to all model saves
like this:

post_save.connect(my_callback_function, sender=None)

or simply:

post_save.connect(my_callback_function)

Then in the callback function test whether the sender is an instanceof
Place before you do anything with it.

-RD


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to