I'm working with RESTAPI with Django (with out DRF). i'm using test.py to to communicate my Django Application.
import requests
import json
BASEURL = '127.0.0.1'
ENDPOINT = 'api/'
def delete_resource(id):
data = {
'id':id,
}
r = requests.delete(BASEURL+ENDPOINT,data=json.dumps(data))
print(r.status_code)
print(r.json())
delete_resource(2)

Mark
The status code
print(r.status_code) 405indicates that the request was not allowed, for some reason.
That's most likely why you get the decode error: it's unlikely that you're getting valid json back if the request was rejected.
So you'll have to investigate why it was rejected:
r? You might want to use a debugger such as in PyCharm./apicorrect? What does the code at that endpoint do?