[Django]-How to set headers in DRF's APIClient() delete() request?

0👍

Apparently, it’s not possible to authenticate with a Private-Token while requesting deletion via APIClient(). But instead, the good old requests library can be used:

import requests

HEADERS = {'PRIVATE-TOKEN': <TOKEN>}

res = ...
if "api_link" in res.data:
    requests.delete(res.data["api_link"], headers=HEADERS)

Leave a comment