I opened a ticket to add async methods to Model: https://code.djangoproject.com/ticket/34112
This would be released in Django 4.2, at minimum. Using async to perform model updates is not likely to be performant, since the queries end up being processed synchronously on a thread anyway. This is because the database libraries Django supports don't have async interfaces. On Fri, Oct 21, 2022 at 4:49 PM Adam Johnson <m...@adamj.eu> wrote: > If you have a suggestion, sure. But from my perspective the docs are > clear. There's an adelete() method doc'd for QuerySet, and not for Model, > and the release note > <https://docs.djangoproject.com/en/4.1/releases/4.1/#asynchronous-orm-interface> > says “QuerySet now provides an asynchronous interface...”. > > On Fri, Oct 21, 2022 at 3:51 PM Jason Johns <jjohns98...@gmail.com> wrote: > >> gotcha, then perhaps a documentation tweak would be in order, on both >> queryset and model pages? because as is, its unclear this is expected. >> >> On Friday, October 21, 2022 at 9:57:33 AM UTC-4 Adam Johnson wrote: >> >>> This is intentional, as it stands. Django 4.1 only added async QuerySet >>> methods, not async Model methods. Async model methods like adelete(), and >>> perhaps asave(), would be the next logical step. >>> >>> On Fri, Oct 21, 2022 at 1:47 PM Jason Johns <jjohn...@gmail.com> wrote: >>> >>>> I came across a reddit post yesterday >>>> <https://www.reddit.com/r/django/comments/y7w5dm/django_async_delete_from_db/>about >>>> `adelete` raising an attribute error >>>> >>>> r = await mymodel.objects.aget(some_name=myname) >>>> await r.adelete() >>>> >>>> would throw an `AttributeError`, >>>> >>>> whereas r = await mymodel.objects.filter(some_name=myname).adelete() >>>> works as expected. >>>> >>>> I was a little curious about this, and adelete >>>> <https://docs.djangoproject.com/en/4.1/ref/models/querysets/#django.db.models.query.QuerySet.adelete> >>>> is >>>> explicitly called out in the queryset docs within the `delete` section. >>>> but the models doc page >>>> <https://docs.djangoproject.com/en/4.1/ref/models/instances/#deleting-objects>only >>>> contains items about `delete`. Is this intentional or not, and if it is >>>> intentional, perhaps a specific call-out in both queryset and model delete >>>> sections would help with clarification. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Django developers (Contributions to Django itself)" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to django-develop...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-developers/82ba40ef-ea73-4492-a2c3-448dbd1b9245n%40googlegroups.com >>>> <https://groups.google.com/d/msgid/django-developers/82ba40ef-ea73-4492-a2c3-448dbd1b9245n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Django developers (Contributions to Django itself)" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to django-developers+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-developers/cbb9dbba-be64-4c97-abfe-0b42ed42ddb3n%40googlegroups.com >> <https://groups.google.com/d/msgid/django-developers/cbb9dbba-be64-4c97-abfe-0b42ed42ddb3n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM3H_JhAYwDhrFs5kpv8C8iq1eGBUbQ1hxOenpZ8rb%2BsqA%40mail.gmail.com.