Is there any better way to do this
us = User.objects.filter(id=someid)
if us.exists():
u = us[0]
As I see in the sql log, us.exists() will execute a sql query, then u = us[0] will execute another query. So we have to do 2 query to get thing done. I just want to ask for a better way to do this
.get()does not make use of django queryset caching. So if you are really want to use and reuse the queryset, better way would be to catchIndexErrorlike: