**asgiref==3.5.0** works fine
--
Ticket URL: <https://code.djangoproject.com/ticket/33795>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> **Django==3.2.13
> asgiref==3.5.2
> **
> If you will try to decorate any ORM function with sync_to_async you will
> wait forever.
>
> **asgiref==3.5.0** works fine
New description:
**Django==3.2.13
asgiref==3.5.2
**
If you will try to decorate any ORM function with sync_to_async you will
wait forever.
**asgiref==3.5.0** works fine
{{{
# models.py
class DTOManager(models.Manager):
@sync_to_async
def filter(self, *args, **kwargs) -> list[BaseModel]:
return [self._dto_mapper(i) for i in
self.model.objects.filter(*args, **kwargs)]
@sync_to_async
def get(self, *args, **kwargs) -> BaseModel:
try:
return self._dto_mapper(self.model.objects.get(*args,
**kwargs))
except self.model.DoesNotExist:
raise ObjectNotFound(f"{self.model.__name__} not found")
class Hotel(models.Model):
id = models.UUIDField(primary_key=True, editable=False)
coordinates = models.PointField(null=True)
dto_objects = DTOManager(dto_mapper=lambda hotel:
HotelDTO(**hotel.curated_data) if hotel else None)
objects = models.Manager()
# services.py
hotels = await Hotel.dto_objects.filter(id=12)
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/33795#comment:1>