Hi
I have problems to post some json data from a python script using
requests to a django view defined as base classed view.
Thinking that problem is with permissions I also installed django rest framework to temporary allow any user to call the view.
the file with post data is looking like:
data = {'k1': 'val1', 'k2': 'val2'}
jdata = json.dumps(data)
r =
requests.post(url, data=jdata, headers=headers)
print r
and the correspondign class based view registrated in urls.py:
class LoadData(APIView):
"""
A view that can accept POST requests with JSON content.
"""
parser_classes = (JSONParser,)
permission_classes = (AllowAny,)
def post(self, request, format=None):
# pdb.set_trace()
now the method post will be not executed.
When I use
put method instead of
post the situation is better but also without data
in request.data or args, kwargs.
I used many times jQuery with ajax and post method in similar cases and it was always working,
so I have no idea what is the difference and what I am missing.
Any hint will be very appreciated and thanks in advance.
Ogi