python - Post data in djangon api and unable to get variable value -


i have created api sending request post didn't vairable in view

def login_list(request):     if request.method == 'post':         data = json.dumps(request.post)         print(data)         serializer = loginserializer(data=request.data)         #print(serializer)         return jsonresponse({"message":'fdsafdsa'})  

when print data print(data) out put coming this

{"{\"login\":122122,\"abvc\":\"544545\"}": ""} 

and calling api in postman

post http://localhost:8000/login/login/  {"login":122122,"abvc":"544545"} 

i not geting value this

print(request.post['login']);

how can value

try request.data instead of request.post. json content sent in body, parsed django rest framework @ runtime.

login_variable = request.data['login'] 

and ensure have added 'jsonparser' in rest_framework settings.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -