Replies: 2 comments
-
this is strange This works: class TestView(viewsets.ViewSet):
def retrieve(self, request, pk, *args, **kwargs):
results["TestView-retrieve"] = pk
return Response(self.request.GET)
# Test a normal connection
communicator = WebsocketCommunicator(
view_as_consumer(TestView.as_view({'get': 'retrieve'})), "/testws/"
)
connected, _ = await communicator.connect()
assert connected
await communicator.send_json_to(
{"action": "retrieve", "request_id": 1, "parameters": {"pk": 42}}
)
response = await communicator.receive_json_from()
assert results["TestView-retrieve"] == 42
assert response == {
"errors": [],
"data": {},
"action": "retrieve",
"response_status": 200,
"request_id": 1,
}
|
Beta Was this translation helpful? Give feedback.
0 replies
-
I have the same issue using the example in the docs:
The request has no parameters:
# Solution
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello @hishnash! I am trying to send the pk to the view but it would not be finding how, I tried the following and it would not be working for me I am using as_view_consumer
Here I leave how the retrieve is defined
Thanks greetings!
Beta Was this translation helpful? Give feedback.
All reactions