The Django QuerySet docs are very clear on this:
get(**kwargs)?
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 class.
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.
filter(**kwargs)
Returns a new QuerySet containing objects that match the given lookup parameters.
Basically use get()
when you want to get a single unique object, and filter()
when you want to get all objects that match your lookup parameters.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…