Django: Async POST Request
I am trying to make an async post request using the following approach:
First of all, I have defined a fixture to return the client:
@pytest.fixture(scope="session")
async def async_app_client():
async with AsyncClient() as client:
yield client
Then i use the client to execute the post request.
@pytest.mark.asyncio
@pytest.mark.django_db()
async def test_single_statistic_task_monitoring(
async_app_client, statistic_object_univariate
):
print(reverse("statistics-list"))
response_post = await async_app_client.post(
reverse("statistics-list"),
statistic_object_univariate,
format="json",
)
The error i am getting is:
AttributeError: 'async_generator' object has no attribute 'post'
However, for examples online many use httpx AsyncClient to make the post request. What is the problem here?