What is the difference between get() and filter() in the ORM, and what exceptions can get() raise?

Last updated 17 June 2026

get() returns exactly one object and raises if it can't, while filter() returns a (possibly empty) queryset of zero or more matches.

  • get(): a single instance:

    • Raises DoesNotExist if no row matches.

    • Raises MultipleObjectsReturned if more than one matches.

    • Use when you expect exactly one record (e.g. by primary key).

  • filter(): a queryset:

    • Never raises for empty results: returns an empty queryset.

    • Lazy and chainable; use when expecting zero, one, or many.

  • Tip: Use get_object_or_404() in views to turn DoesNotExist into a 404.

  • https://medium.com/@josephfrancizz444/filter-vs-get-in-django-when-to-use-what-fef2217f3e67
  • https://www.reddit.com/r/django/comments/1hb2rj2/difference_between_get_and_filter_cant_understand/
  • https://docs.djangoproject.com/en/6.1/topics/db/queries/
  • https://django.readthedocs.io/en/stable/ref/models/querysets.html
  • https://www.geeksforgeeks.org/python/how-to-fix-multipleobjectsreturned/
  • https://www.geeksforgeeks.org/python/django-query-set-get/
  • https://www.geeksforgeeks.org/python/django-interview-questions/
All Django interview questions