#9318: "Virtual" behaviour for signal dispatcher and model inheritance
-------------------------------------+--------------------------------------
Reporter: svetlyak40wt | Owner: nobody
Status: new | Milestone:
Component: Core framework | Version: 1.0
Resolution: | Keywords: model inheritance,
signals, dispatch
Stage: Accepted | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
-------------------------------------+--------------------------------------
Changes (by benbest86):
* cc: benbest86 (added)
Comment:
I have come across the need for this as well - especially when overriding
defaults of other projects by inheritance instead of forking.
One (relatively) easy way to deal with this is to listen on the relevant
child class signals and send the base class signal from there. This way
you can still attach all of your common signals to the base class and not
worry about adding a new one to each child for every new listening
function.
Ex:
{{{
class Child(Parent):
pass
def call_parent_post_save(sender, instance, created, **kwargs):
post_save.send(sender=Parent,
instance=Parent.objects.get(id=instance.id), created=created, **kwargs)
post_save.connect(call_parent_post_save, sender=Child)
}}}
Not sure if there is a better way to get the proper instance though -
haven't found a great way to do this directly from the existing instance
instead of using a query. Any thoughts would be appreciated.
--
Ticket URL: <http://code.djangoproject.com/ticket/9318#comment:6>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---