1

I have an url which pass for my view key=value pairs inside it. For example

http://example.com/urlcut/?name=mike

I found that i can parse this kind of urls by urllib.parse.parse_qsl method. It's take url as first argument of str type and return list of tuples with key,value pairs.

My problem is that i didnt found how to execute full url from django Request object to futher parsing it and execute from it key=value pair. I tried request.body and request.QUERY_STRING

def urlcut(request):
     a=urllib.parse.parse_qsl(request.QUERY_STRING,.....

But both of abome methods didnt give me what i.need

1 Answers1

2

I found answer the appropriate way for parse mentioned key value pairs. We can acces them by

url="http://url.com/?key=val&key1=val1"
def get_data(request):
    data=request.GET.get("key")
    data1=request.GET.get("key1")