AssertionError: Expected a `Response`, `HttpResponse` or `StreamingHttpResponse` to be returned from the view, but received a “
async def send_stock_updates(symbol): while True: stock_info = get_one_stock_info(symbol) # Send stock info over WebSocket channel_layer = get_channel_layer() await async_to_sync(channel_layer.group_send)( ‘stock_updates’, # Group name { ‘type’: ‘send_stock_info’, ‘stock_info’: json.dumps(stock_info), } ) await asyncio.sleep(1) class OneStockInfoAPIView(APIView): async def get(self, request): symbol = request.query_params.get(‘symbol’) if not symbol: return Response({‘error’: ‘symbol parameter is required’}, status=status.HTTP_400_BAD_REQUEST) asyncio.create_task(send_stock_updates(symbol)) return JsonResponse({‘message’: ‘WebSocket […]
django took too long to shut down and was killed
I am using Django Channel for a real-time sending and saving data but when I refresh the page the error came up. I don’t know why but, on first load the system is okay but if I reload the page the log appears.