You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 in skip_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
defcreate(self, **kwargs):
""" Create a new object with the given kwargs, saving it to the database and returning the created object. """obj=self.model(**kwargs)
self._for_write=Trueobj.save(force_insert=True, using=self.db)
returnobj
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 exit
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 exit
Does anyone have any comments on this?
And if I were to make the proposed changes, would they PR be accepted?
The text was updated successfully, but these errors were encountered: