#35083: Make django.utils.decorators.method_decorator work with async functions.
------------------------------+------------------------------------
     Reporter:  Drew Winstel  |                    Owner:  nobody
         Type:  New feature   |                   Status:  new
    Component:  Utilities     |                  Version:  5.0
     Severity:  Normal        |               Resolution:
     Keywords:  async         |             Triage Stage:  Accepted
    Has patch:  0             |      Needs documentation:  0
  Needs tests:  0             |  Patch needs improvement:  0
Easy pickings:  0             |                    UI/UX:  0
------------------------------+------------------------------------

Comment (by Carlton Gibson):

 This ticket seems correct (`method_decorator` should work with `async def`
 methods).

 Out of interest though, `View` standardly has a sync `dispatch`, which
 you've overridden here:

 {{{
 class View1(View):
     @method_decorator(ensure_csrf_cookie)
     async def dispatch(
         self, request: HttpRequest, *args: Any, **kwargs: Any
     ) -> HttpResponse:
         return await super().dispatch(request, *args, **kwargs)

 }}}

 ... so would `method_decorator` work already for the ''usual cases'',
 decorating `dispatch`? 🤔

 Likely off-topic but just for future context, Drew could you maybe briefly
 say how it comes up — I guess the Strawberry base class is `async def` all
 the way... or ... 🤔?
 Thanks.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35083#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018cd395f5c6-30524fee-3327-4186-b9f6-fa5424842d18-000000%40eu-central-1.amazonses.com.

Reply via email to