[Answered ]-DRF APIClient Delete data arrives in request.data, not request.query_params

1👍

Though some good options have been proposed, they didn’t work with DRF’s APIView. I ended up using urllib and encode it manually:

import pytest
from urllib.parse import urlencode
from rest_framework.test import APIClient


@pytest.fixture()
def client():
    client = APIClient()
    client.force_authenticate()
    yield client


class TestDelete:

    def test_delete(client):
        response = client.delete(f'/comment{urlencode(data)}')

Leave a comment