Open TonisPiip opened 11 months ago
Thanks for this suggestion!
I like the context manager approach, I've seen similar patterns in other projects like django-modeltranslation
:
If you want to provide an implementation for this let me know, if not when I have some spare time I could try to do it.
Due to the current way skip_hooks works, you need to pass it into save(), you can not suppress hooks in the case of using
model.objects.get_or_create
. You can't just pass inskip_hooks
to that method as it's used when initing the new model, and in inital get request.For create() it would be possible to eaisly fix by popping out skip_hooks from init's kwags
and then in save also check the non_null sate of self._get_hooks
But that doesn't fix that
skip_hooks=True
will be passed to the queryset filter. So in that case, the only solution would be some global var/instance which is set using enter and exitDoes anyone have any comments on this?
And if I were to make the proposed changes, would they PR be accepted?