As per docs since v4.2 Django comes with async version of delete method named adelete(). But I do not understand how to delete an object from DB using it.
db_object = await DbModel.objects.aget(pk=module_id)
await db_object.adelete() # doesn't work
It fails with an error:
"AttributeError: 'DbModel' object has no attribute 'adelete'
What is wrong?
>Solution :
adelete is a queryset method, not a method on the model.
So you can’t delete single object using adelete.
https://docs.djangoproject.com/en/4.2/ref/models/instances/#deleting-objects
try this
await DbModel.objects.filter(pk=module_id).adelete()