Back to search

What is the difference between get and filter in Django ORM?

`get()` expects exactly one row and raises errors otherwise, while `filter()` returns a QuerySet that can contain zero or more rows.

Django Easy Theory

What is the difference between get and filter in Django ORM?

`get()` expects exactly one row and raises errors otherwise, while `filter()` returns a QuerySet that can contain zero or more rows.

  • get returns one object
  • filter returns QuerySet
  • Use get only when uniqueness is expected

What is the difference between get and filter in Django ORM?