Python Asyncio in Django View

前端 未结 4 1436
清歌不尽
清歌不尽 2020-12-13 20:52

I would like to make two POST requests from an API on a Django view at the same time.

This is how I would do it outside of django.

import asyncio
imp         


        
4条回答
  •  情话喂你
    2020-12-13 21:25

    Django is a synchronous framework so you can't use any async/await in the views because of there no loop or something like that.

    You really can use Django channels library for it, but it will make your views asynchronous under the hood by itself, you don't need to use async also, just connect the channels a go on coding as you do it before, without any async features.

提交回复
热议问题