Django – Difference Between Filter and Get


For the new comers Django’s Get and Filter functions may be consuming when it comes to decide which one to use. The primary difference between the two is Get will return exactly one object while Filter will return a query object even if the result set contains only a single object.


Returns the object matching the given lookup parameters, which should be
in the format described in Field lookups.

get() raises MultipleObjectsReturned if more than one object was found.
The MultipleObjectsReturned exception is an attribute of the model

get() raises a DoesNotExist exception if an object wasn’t found for the
given parameters. This exception is also an attribute of the model class.


Returns a new QuerySet containing objects that match the given lookup parameters.

You can query this QuerySet again and again applying different filters.

Use GET when you want to fetch a single unique object, and FILTER when you want to get all objects that match your specific lookup parameters.

Hope this helps.
Good Luck,