Bird
0
0

Identify the issue in this async Django ORM code snippet:

medium📝 Debug Q7 of 15
Django - Async Django
Identify the issue in this async Django ORM code snippet:
async def fetch_active_users():
    users = User.objects.filter(active=True).aall()
    return users
AMissing 'await' keyword before the async ORM call
BUsing 'filter' instead of 'get' for multiple users
CReturning the queryset directly without converting to list
DIncorrect method name 'aall()', should be 'all()'
Step-by-Step Solution
Solution:
  1. Step 1: Check async method usage

    The method 'aall()' does not exist; the correct method is 'all()' which should be awaited.
  2. Step 2: Identify incorrect method name

    Using 'aall()' causes AttributeError; the method should be 'all()' with 'await'.
  3. Final Answer:

    Incorrect method name 'aall()', should be 'all()' -> Option D
  4. Quick Check:

    Invalid method name causes error [OK]
Quick Trick: Use 'await queryset.all()' not 'aall()' [OK]
Common Mistakes:
MISTAKES
  • Assuming 'aall()' is a valid async method
  • Confusing 'all()' with 'aall()'
  • Not expecting AttributeError on invalid method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Django Quizzes