#9318: "Virtual" behaviour for signal dispatcher and model inheritance
-------------------------------------+-------------------------------------
     Reporter:  Alexander Artemenko  |                    Owner:  (none)
         Type:  New feature          |                   Status:  new
    Component:  Core (Other)         |                  Version:  1.0
     Severity:  Normal               |               Resolution:
     Keywords:  model inheritance,   |             Triage Stage:  Accepted
  signals, dispatch, proxy,          |
  subclass                           |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Aymeric Augustin):

 I found a workaround that doesn't require patching Django, but that may
 affect performance:

 {{{#!python
 # Because of https://code.djangoproject.com/ticket/9318, declaring
 # `@dispatch.receiver(..., sender=myapp.MyModel, ...)` wouldn't
 # trigger this function when a subclass is saved. So we perform the check
 # manually with `issubclass(sender, myapp.MyModel)`. This is
 # inefficient because any save(), for any model, now calls this function.
 @dispatch.receiver(signals.post_save)
 def request_saved(sender, instance, created, **kwargs):
     if not issubclass(sender, myapp.MyModel):
         return
    ...
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/9318#comment:33>
Django <https://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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/070.af5e5b90428eacac231c95e5f4826eb8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to