Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up

What is the difference between get() and filter() on a QuerySet?

  1. A get() returns a single object and raises an exception if there is not exactly one match; filter() returns a QuerySet
  2. B filter() returns one object
  3. C get() returns a list
  4. D They are identical
Answer

get() returns a single object and raises an exception if there is not exactly one match; filter() returns a QuerySet

get() raises DoesNotExist or MultipleObjectsReturned. filter() returns a possibly empty QuerySet and never raises for zero matches.

All Django MCQs

Login to manage your account

Please enter a valid email address.
Forgot Password?
Please enter a valid password.
OR

Don't have an account yet? Sign up as