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
Hey, since Django ORM is starting to support async more and more, I'm wondering if you guys thought about adding async support to InheritanceManager (and InheritanceQuerySet respectively)?
Environment
Django Model Utils version: 4.2.0
Django version: 4.1
Python version: 3.10
Other libraries used, if any: not-relevant
Code examples
So far I was thinking of primitive solution to this problem and I've ended up with something like this, but I have not tested it yet (hopefully will get to testing it in few days). Do you think it should work, or is there some bigger problem about integrating async support to InheritanceManager?
classExtendedInheritanceQuerySet(InheritanceQuerySet):
"""InheritanceQuerySet from django-model-utils extended for async methods."""asyncdefaselect_subclasses(self, *subclasses):
returnawaitsync_to_async(self.select_subclasses)(*subclasses)
asyncdefaget_subclass(self, *args, **kwargs):
returnawaitsync_to_async(self.get_subclass)(*args, **kwargs)
classExtendedInheritanceManager(InheritanceManager):
"""InheritanceManager from django-model-utils extended for async methods."""# todo also possible to create manager dynamically using `from_queryset` or `as_manager`_queryset_class=ExtendedInheritanceQuerySetasyncdefaselect_subclasses(self, *subclasses):
returnawaitself.get_queryset().aselect_subclasses(*subclasses)
asyncdefaget_subclass(self, *args, **kwargs):
returnawaitself.get_queryset().aget_subclass(*args, **kwargs)
The text was updated successfully, but these errors were encountered:
Problem
Hey, since Django ORM is starting to support async more and more, I'm wondering if you guys thought about adding async support to
InheritanceManager
(andInheritanceQuerySet
respectively)?Environment
Code examples
So far I was thinking of primitive solution to this problem and I've ended up with something like this, but I have not tested it yet (hopefully will get to testing it in few days). Do you think it should work, or is there some bigger problem about integrating async support to
InheritanceManager
?The text was updated successfully, but these errors were encountered: