QuerySetsLesson 36Free preview
QuerySet Get
This lesson is part of Django · All levels
Summary
The get() method takes a single object that matches the criteria, usually via the primary key. If nothing matches, throw the exception DoesNotExist. Unlike filter() which returns QuerySet.
Key points
- Returns a single object
- Suitable for primary keys
- Throwing out the Doesn't Exist when it's not found.
- Throw MultipleObjectsReturned when more than one
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.