--A memorandum for yourself. --Organized how to get GET request parameters
I don't know if it's essentially correct, but for now I can get it.
http://~~~~~~~~~~~?query_param=AAA Gets the ** query_param value ** when is specified.
Get query parameters
from rest_framework.views import APIView
class SampleView(APIView):
def get(self, request):
if "query_param" in request.GET:
# query_Processing when param is specified
param_value = request.GET.get("query_param")
else:
# query_Processing when param is not specified
It is better to check if there is a value.
In get (), if the value corresponding to the key does not exist, It seems that you can specify the default value.
Like this??
Specifying the default value in get
param_value = request.GET.get(key="query_param", default="hogehoge")
http://docs.djangoproject.jp/en/latest/ref/request-response.html
Recommended Posts