Notice
                              
                          
                        
                          
                          
                            Recent Posts
                            
                        
                          
                          
                            Recent Comments
                            
                        
                          
                          
                            Link
                            
                        
                    | 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 | 
| 12 | 13 | 14 | 15 | 16 | 17 | 18 | 
| 19 | 20 | 21 | 22 | 23 | 24 | 25 | 
| 26 | 27 | 28 | 29 | 30 | 31 | 
                            Tags
                            
                        
                          
                          - GraphQL
- Django-allauth
- for loop
- allauth
- array
- graphene-django
- SQL
- python
- FastAPI
- check_password
- flask
- tkinter Radio 동적버튼
- numpy
- Django
                            Archives
                            
                        
                          
                          - Today
- Total
객
[Django] Django ORM 본문
일반 SQL문에 WHERE절에 대한 DJANGO ORM 표현방법
───────────────────────────────────────────
   조회 조건                   설명     
─────────────┬─────────────────────────────
__contains  	 	  │ 지정한 문자열을 포함하는 데이터 조회
            	 	  │ Post.objects.filter(title__contains=’test’)
─────────────┼─────────────────────────────
__icontains  		  │ 지정한 문자열의 대소문자 구분없이 포함하는 데이터 조회
             		  │  Post.objects.filter(title__icontains=’this’)
─────────────┼─────────────────────────────
__lt         		  │ 값이 작은 경우(lt: less than)
             		  │  Post.objects.filter(published_at__lt=timezone.now()) 
─────────────┼─────────────────────────────
__lte       		  │ 값이 작거나 같은 경우(lte: less than or equal)
             		  │  Post.objects.filter(published_at__lt=timezone.now())
─────────────┼─────────────────────────────
__gt         		  │ 값이 큰 경우(gt: greater than)
            		  │  Post.objects.filter(published_at__gt=timezone.now())
─────────────┼─────────────────────────────
__gte       		  │ 값이 크거나 같은 경우(gt: greater than or equal)
           	          │  Post.objects.filter(published_at__gte=timezone.now())
─────────────┼─────────────────────────────
__in         		  │ 주어진 리스트에 포함되는 데이터 조회
             		  │  Post.objects.filter(id__in=[1, 2, 3])
─────────────┼─────────────────────────────
__year      		  │ 해당 년도 조회
             		  │  Post.objects.filter(created_at__year=’2019’)
─────────────┼─────────────────────────────
__year       		  │ 해당 월로 조회
             		  │  Post.objects.filter(created_at__month=’5’)
─────────────┼─────────────────────────────
__day        		  │ 해당 일로 조회
             		  │  Post.objects.filter(created_at__day=’21’)
─────────────┼─────────────────────────────
__isnull     		  │ 해당 열이 null인 데이터 조회
             		  │  Post.objects.filter(published_at__isnull=True)
─────────────┼─────────────────────────────
__startswith 		  │ 해당 문자열로 시작하는 데이터 조회
             		  │ Post.objects.filter(title__startswith=’This’)
─────────────┼─────────────────────────────
__istartswith		  │ 대소문자를 가리지 않고 해당 문자열로 시작하는 데이터 조회
             		  │  Post.objects.filter(title__istartswith=’this’)
─────────────┼─────────────────────────────
__endswith   		  │ 해당 문자열로 끝나는 데이터 조회
             		  │  Post.objects.filter(title__endswith=’title’)
─────────────┼─────────────────────────────
__iendswith  		  │ 대소문자를 가리지 않고 해당 문자열로 끝나는 데이터 조회
             		  │  Post.objects.filter(title__iendswith=’title’)
─────────────┼─────────────────────────────
__range      		  │ 범위를 지정하여 조회(sql의 between)
             		  │  Post.objects.filter(id__range=(1, 10)
─────────────┴─────────────────────────────2). JOIN 관련
brownbears.tistory.com/101
3). fields 이름 변경 방법
brownbears.tistory.com/100?category=168282
4). FilterSet Guide
brownbears.tistory.com/98?category=168282
5). Django Rest Framework
brownbears.tistory.com/97?category=168282
'[PL] > Python' 카테고리의 다른 글
| [Django] Django ORM (0) | 2021.09.13 | 
|---|---|
| Graphql기반한 CRUD중 - Select (0) | 2021.09.13 | 
| [정리중] Django ISSUE (0) | 2021.07.17 | 
| DJANGO settings.py 의 db(Postgresql, cubrid, sqlite3, mariadb)설정 (0) | 2013.12.05 | 
| Django 관련 (0) | 2013.12.02 | 
