Difference between Django’s filter() and get() methods?
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The Difference between Django’s filter() and get() methods are: get throws an error if there’s no object matching the query. filter will return an empty queryset…
Basically use
get()
when you want to get a single unique object, andfilter()
when you want to get all objects that match your lookup parameters.mymodel=model.objects.get(name='pol')
mymodel=model.objects.filter(name='pol')