python - Speeding up django .exists() -
i have query translationstep.objects.filter(step_id=pk)
. need check if object exist or not , if so, return object (or several objects). have read .exists()
more fastest way it, should make 2 requests.
if translationstep.objects.filter(step_id=pk).exists(): return translationstep.objects.filter(step_id=pk) else: return none
how can optimise it?
you shouldn't @ all. filter()
return empty queryset if there no match, false in boolean context.
Comments
Post a Comment