How can I save a model, such that signals arent sent. (post_save and pre_save)
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
This ticket has been marked as "wontfix" because:
It's a bit of a hack, but you can do something like this:
use a unique identifier with a filter and then use the update method of the queryset (which does not trigger the signals)
also you can read more here django docs
If you have mutual relations on models and their signals still you can decouple signal's logic to have more signals of same type, and handle your logic in more sophisticated way:
You can check in signals, the state of object:
kwargs['created']
You can check the state of any pasted extra value: So in one signal, you will read at first:
and in another place, before
save()
you will just set thatskip_signals
on the specific object, in specific situation. (there is no need to define it as model field)You can also do not emit signals:
save_without_signals()
,filter(pk=<>).update(...)
There is currently a ticket pending a Django design decision for this feature.
Included in the ticket is a diff for a patch with the proposed implementation.