Music : Don't Hate Me
Band : Jingle Punks
무료한 개애애!발 인생의 청량 음료는 역시 Music 아니겠어요?!
앞에서 or, and를 통해서
not : 그 조건 빼고줘~~!
너무 쉽죠잉?
exclude(조건)
Q앞에
~틸드 연산자 보이나용? 그래야
NOT`의 의미에요.5미만의 id말고
보여줘!
sqlite> select id, username, first_name, last_name, email from auth_user where not id < 5;
id username first_name last_name email
-- -------- ---------- --------- --------------------
5 sharukh sharukh Misra sharukh@hotmail.com
6 Ritesh Ritesh Deshmukh ritesh@yahoo.com
7 Billy Billy Sharma billy@gmail.com
8 Radha Radha George radha@gmail.com
9 sohan Sohan Upadhyay sohan@aol.com
10 Raghu Raghu Khan raghu@rediffmail.com
11 rishab Rishabh Deol rishabh@yahoo.com
sqlite>
위의 SQL 출력된거랑 비교하니 잘나온거 보이조?
>>> queryset = User.objects.exclude(id__lt=5)
>>> queryset
<QuerySet [<User: sharukh>, <User: Ritesh>, <User: Billy>, <User: Radha>, <User: sohan>, <User: Raghu>, <User: rishab>]>
>>>
거시기 Q객체는 어떻게 적용하냐고요? 아래를 보시조~
id__lt
언더바 2개라는거~ 깜빡하면 안되요.
>>> from django.db.models import Q
>>> queryset = User.objects.filter(~Q(id__lt=5))
>>> queryset
<QuerySet [<User: sharukh>, <User: Ritesh>, <User: Billy>, <User: Radha>, <User: sohan>, <User: Raghu>, <User: rishab>]>
>>>