[Django] #35701: Class BaseView. Use gzip_page Error: 'coroutine' object has no attribute 'streaming'

14 views
Skip to first unread message

Django

unread,
Aug 22, 2024, 6:58:17 AM8/22/24
to django-...@googlegroups.com
#35701: Class BaseView. Use gzip_page Error: 'coroutine' object has no attribute
'streaming'
-------------------------+-----------------------------------------
Reporter: Ingward | Type: Bug
Status: new | Component: Generic views
Version: 5.1 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------+-----------------------------------------
Can I use a decorator "gzip_page" with an asynchronous server and an
asynchronous function async def get(self, request, *args, **kwargs): ?


{{{
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
from django.views.decorators.gzip import gzip_page

@method_decorator([never_cache, csrf_protect, gzip_page], name='dispatch')
class AccountIn(View):
async def get(self, request, *args, **kwargs):
return TemplateResponse(request, 'accounts/login.html',
context={})
}}}

Server :

import uvicorn

if __name__ == '__main__':
uvicorn.run("app.asgi:application", reload=True, port=5000,
log_level="info", lifespan='auto')

Error:

'coroutine' object has no attribute 'streaming'
...Lib\site-packages\django\middleware\gzip.py, line 20, in
process_response
--
Ticket URL: <https://code.djangoproject.com/ticket/35701>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Aug 22, 2024, 7:02:23 AM8/22/24
to django-...@googlegroups.com
#35701: Class BaseView. Use gzip_page Error: 'coroutine' object has no attribute
'streaming'
-------------------------------+--------------------------------------
Reporter: Ingward | Owner: (none)
Type: Bug | Status: new
Component: Generic views | Version: 5.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by Ingward:

Old description:

> Can I use a decorator "gzip_page" with an asynchronous server and an
> asynchronous function async def get(self, request, *args, **kwargs): ?
>

> {{{
> from django.views.decorators.cache import never_cache
> from django.views.decorators.csrf import csrf_protect
> from django.views.decorators.gzip import gzip_page
>
> @method_decorator([never_cache, csrf_protect, gzip_page],
> name='dispatch')
> class AccountIn(View):
> async def get(self, request, *args, **kwargs):
> return TemplateResponse(request, 'accounts/login.html',
> context={})
> }}}
>
> Server :
>
> import uvicorn
>
> if __name__ == '__main__':
> uvicorn.run("app.asgi:application", reload=True, port=5000,
> log_level="info", lifespan='auto')
>
> Error:
>
> 'coroutine' object has no attribute 'streaming'
> ...Lib\site-packages\django\middleware\gzip.py, line 20, in
> process_response

New description:

Can I use a decorator "gzip_page" with an asynchronous server and an
asynchronous function async def get(self, request, *args, **kwargs): ?


{{{
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
from django.views.decorators.gzip import gzip_page

@method_decorator([never_cache, csrf_protect, gzip_page], name='dispatch')
class AccountIn(View):
async def get(self, request, *args, **kwargs):
return TemplateResponse(request, 'accounts/login.html',
context={})
}}}

Server :

{{{
import uvicorn

if __name__ == '__main__':
uvicorn.run("app.asgi:application", reload=True, port=5000,
log_level="info", lifespan='auto')
}}}


Error:

'coroutine' object has no attribute 'streaming'
...Lib\site-packages\django\middleware\gzip.py, line 20, in
process_response

--
--
Ticket URL: <https://code.djangoproject.com/ticket/35701#comment:1>

Django

unread,
Aug 22, 2024, 8:51:42 AM8/22/24
to django-...@googlegroups.com
#35701: Class BaseView. Use gzip_page Error: 'coroutine' object has no attribute
'streaming'
-------------------------------+--------------------------------------
Reporter: Ingward | Owner: (none)
Type: Bug | Status: closed
Component: Generic views | Version: 5.1
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Sarah Boyce):

* resolution: => duplicate
* status: new => closed

Comment:

I think you can see the supported decorator list in the
[https://docs.djangoproject.com/en/5.1/topics/async/#decorators async
documentation].
So I think `gzip_page` - yes but `method_decorator` - no
I believe this is a duplicate of #35083
--
Ticket URL: <https://code.djangoproject.com/ticket/35701#comment:2>
Reply all
Reply to author
Forward
0 new messages