
IT/파이썬 2023. 4. 26.
Django - response 객체에 쿼리스트링 추가
response 보낼때 쿼리 스트링 붙여서 보내고 싶다면, 아래 코드를 참고하세요. response = redirect("order_view", pk=order.id) response["Location"] += "?" + request.POST.get("querystring") return response Location 이라는 필드가 있는 지 어케 아는지? 이렇게 작성을 해도 되고, from django.http import HttpResponse def my_view(request): # Get the query string from the request query_string = request.GET.get("querystring") # Create the URL with the query stri..

IT/DB 2021. 6. 21.
Flask MongoEngine 쿼리 filter() 함수 문자열 - Query Operators
Flask MongoEngine 쿼리 filter() 함수 문자열에 대해서 정리해 둬보자. (사실 해본거 하나만 더 적어두자, 해본거니깐) 맨날 = 만 쓰려니 MongoEngine 홈페이지에 가면 다양한 operator 가 있다 쿼리로 사용할 수 있는, 가장 기본적인 예제로 아래와 같이 18세 이하 사용자를 찾아라 같은 예제가 있다. # Only find users whose age is 18 or less young_users = Users.objects(age__lte=18) 즉, 필드명에다가 언더스코어 2개를 넣고 원하는 기능어를 넣으면 쿼리 스트링이 완성된다. 필드명__operator 오퍼레이터의 종류는 아래와 같다. https://docs.mongoengine.org/guide/querying...
