#7.2 QuerySets (07:01) - airbnb-clone-backend

star_is_mine·2022년 11월 8일
0

airbnb_clone_coding_backend

목록 보기
11/14

배운점

queryset 은 lazy 하다 라는 말의 의미를 배웠습니다.

# 여러개의 filter 조건을 동시에 중첩 사용시 예제.
Entry.objects.filter(headline__startswith='What').exclude(pub_date__gte=datetime.date.today())

Or 

Entry.objects.filter(headline__startswith='What', name__icontains="seoul", )
# 위와 같이 여러개의 조건을 ' , ' 콤마로 연결해도 됩니다. 

queryset 은 lazy 하다 라는 말의 의미

# Room.object 가 100억 개가 존재한다고 가정할 때 
# 만약 queryset 이 lazy 하지 않는다면 
Room.object.all() # 명령 실행시 컴퓨터는 멈출 것이다. 
# 그러나 queryset 이 lazy 하기 때문에 100억 개의 오브젝트가 존재하는 Room.object 를 전부 호출해도 실제로 해당 데이터를 추출하는 등의 명령을 실행하지 않는 이상 컴퓨터는 멈추지 않습니다. 

핵심명령어 정리

.filter()
.exclude()
.include()


None


Note

profile
i have a dream and I will make my dreams come true.

0개의 댓글