I have the following code for a view of DRF:
from rest_framework import viewsets
class MyViewSet(viewsets.ViewSet):
def update(self, request, pk = None):
print pk
print request.data
I call the URL via python-requests in the following way:
import requests
payload = {"foo":"bar"}
headers = {'Content-type': 'application/json'}
r = requests.put("https://.../myPk", data= payload, headers=headers)
but when the request is received from the server, request.data is empty. Here there is the output:
myPk
<QueryDict: {}>
How can I fix this problem?