#26642: ModelSignal.disconnect() does not work with lazy references
----------------------------------------------+--------------------
     Reporter:  AlexHill                      |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  master
     Severity:  Normal                        |   Keywords:
 Triage Stage:  Unreviewed                    |  Has patch:  1
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+--------------------
 `ModelSignal.connect()` lets you pass a string model reference as a
 sender, and will connect the signal as soon as the model is available.

 For consistency, `ModelSignal.disconnect()` should work in the same way.
 Currently, if you call `connect()` followed by `disconnect()` before the
 model is available, the signal will remain connected:

 {{{#!python

 >>> def receiver(sender, **kwargs):
 ...     print("post_init sent by %r" % sender)
 ...
 >>> post_init.connect(receiver, sender='some_app.SomeModel')
 >>> post_init.disconnect(receiver, sender='some_app.SomeModel')
 False
 >>>
 >>> class SomeModel(models.Model):
 ...     class Meta:
 ...         app_label = 'some_app'
 ...
 >>> s = SomeModel()
 post_init sent by <class 'SomeModel'>
 >>>
 }}}

 There's a patch with the necessary changes in PR 6629.

--
Ticket URL: <https://code.djangoproject.com/ticket/26642>
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/051.72eafa552df7da4b434044b06a315cb2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to