Bird
0
0

Given this async code:

medium📝 Predict Output Q5 of 15
Django - Async Django
Given this async code:
async def get_active_users():
    return await User.objects.filter(active=True).aall()

What does 'aall()' do?
ARaises an AttributeError because 'aall' is invalid
BReturns a count of active users
CReturns all filtered User objects asynchronously
DReturns a synchronous QuerySet
Step-by-Step Solution
Solution:
  1. Step 1: Check method name validity

    Django async ORM uses 'all()' with 'await', no 'aall()' method exists.
  2. Step 2: Predict error

    Calling 'aall()' will cause AttributeError because method is invalid.
  3. Final Answer:

    Raises an AttributeError because 'aall' is invalid -> Option A
  4. Quick Check:

    Invalid async method name causes AttributeError [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