Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
One of the benefits of Django`'s `QuerySet is that you can apply filters on it, slice it and move it around your classes without actually hitting the database until you do so.

One of the ways that executes the query is using iteration:
for c in Course.objects.all():
print(c.title)
NOTE: the first time you iterate over the query, it hits the database and get the result NOT in each iteration.

In the below ways your query will be evaluated (executed):
- repr
- len
- list (e.g.: `list(Entry.objects.all())`)
- bool

#python #django #querySet #query_set #evaluation