I need to check if Model.objects.filter(...) turned up anything, but do not need to insert anything. My code so far is:
user_pass = log_in(request.POST) # form class
if user_pass.is_valid():
cleaned_info = user_pass.cleaned_data
user_object = User.objects.filter(email = cleaned_info['username'])
Since
filterreturns aQuerySet, you can use count to check how many results were returned. This is assuming you don’t actually need the results.After looking at the documentation though, it’s better to just call len on your filter if you are planning on using the results later, as you’ll only be making one sql query: