我想将 API 的行为更改为 JSON 触发(从浏览器调用),但由于我对 Python 的了解有限,我什至无法从 Python 客户端调用它。
有人可以帮助我如何按照手册所示进行操作吗?这是我的简单客户端:
class GenericAsyncAPIConsumerWith(GenericAsyncAPIConsumer):
async def websocket_connect(self, message):
# Super Save
await super().websocket_connect(message)
# Initialized operation
await self.model_activity.subscribe()
class UserConsumer(ObserverModelInstanceMixin, GenericAsyncAPIConsumerWith):
queryset = Course.objects.order_by("-start_time")
serializer_class = UserSerializer
# permission_classes = [IsAuthenticated]
@model_observer(User)
async def model_activity(self, message, observer=None, **kwargs):
# send activity to your frontend
await self.send_json(message)
杨魅力
翻翻过去那场雪
相关分类