协程和 Django 点击劫持中间件

coroutines and Django clickjacking middleware

我正在尝试将 aiohttp 库与 Django 一起使用。我已按照教程进行操作,但在将我的 view 方法之一定义为 async 时出现以下错误。

Traceback (most recent call last):
  File "/Users/.../lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
    response = get_response(request)
  File "/Users/.../lib/python3.6/site-packages/django/utils/deprecation.py", line 97, in __call__
    response = self.process_response(request, response)
  File "/Users/.../lib/python3.6/site-packages/django/middleware/clickjacking.py", line 26, in process_response
    if response.get('X-Frame-Options') is not None:
AttributeError: 'coroutine' object has no attribute 'get'

我的最小工作示例如下:

async def conversion_form_process(request):
    if request.method == 'POST':
        form = ConversionForm(request.POST)
        # check whether it's valid:
        if form.is_valid():
            return HttpResponseRedirect('/thanks/')

    else:
        form = ConversionForm()

    return render(request, 'mainpage.html', {'form': form})

这表明它与 async 关键字有关,但我不知道如何解决它。任何帮助深表感谢。谢谢!

抱歉,aiohttpDjango 不兼容。

它使用完全不同的范式。