#26715 closed Uncategorized (invalid)
Model objects with deferred fields don't send pre_save or post_save signals to receivers with explicit sender
Reported by: | Evan Heidtmann | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.9 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Because the objects returned by Model.objects.only(*fields)
are of a special object type, and that type is used as the sender
for the post_save
signal send, these deferred objects never invoke signal handlers that registered with an explicit signal sender.
Something like this should reproduce:
# models.py class MyModel(models.Model): bigfield = models.TextField(null=True, blank=True) # signals.py @receiver.register(post_save, sender=models.MyModel) def mymodel_post_save_handler(sender, **kwargs): print "handler called" # repro code m = MyModel.objects.create() # (handler is called) deferred_m = MyModel.objects.only('id').get(id=m.id) deferred_m.bigfield = 'yo' deferred_m.save() # (handler should be called, but is not)
Happy to produce a proper test app/project if needed.
Evan
Change History (2)
comment:1 by , 8 years ago
Description: | modified (diff) |
---|
comment:2 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Version: | 1.10 → 1.9 |
Note:
See TracTickets
for help on using tickets.
Hi ezheidtmann,
You've reported this bug against Django 1.10 but this should have been solved by 7f51876f99851fdc3fef63aecdfbcffa199c26b9 (#26207) which stopped dynamically creating custom model proxy classes for deferred fields and which is part of 1.10. The deletion signal part was tested to be fixed in #18100.
Please reopen this ticket if you're still experiencing this issue with Django 1.10a1.