Django: Getting Started Transcripts
Chapter: Django ORM and Databases
Lecture: Using '.objects.get()' for access by key

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Another method of the query manager is get. This returns a single object that maps to the arguments given.
0:10 In this case, I have asked for an author with an id of one. This gets returned into the result variable.
0:17 Note that get will return an error if there are multiple objects that match your query
0:23 In the case of the id, which is the primary key, this won't happen. There's the result and results last name and id. And just as a reminder,
0:37 here's the Dickens object and you can compare the two.

Talk Python's Mastodon Michael Kennedy's Mastodon