mirror of
https://github.com/django/django.git
synced 2025-08-03 10:34:04 +00:00
Fixed #33611 -- Allowed View subclasses to define async method handlers.
This commit is contained in:
parent
2ee4caf56b
commit
9ffd4eae2c
6 changed files with 168 additions and 4 deletions
|
@ -77,6 +77,17 @@ MRO is an acronym for Method Resolution Order.
|
|||
<how-django-processes-a-request>` to the ``args`` and ``kwargs``
|
||||
attributes, respectively. Then :meth:`dispatch` is called.
|
||||
|
||||
If a ``View`` subclass defines asynchronous (``async def``) method
|
||||
handlers, ``as_view()`` will mark the returned callable as a coroutine
|
||||
function. An ``ImproperlyConfigured`` exception will be raised if both
|
||||
asynchronous (``async def``) and synchronous (``def``) handlers are
|
||||
defined on a single view-class.
|
||||
|
||||
.. versionchanged:: 4.1
|
||||
|
||||
Compatibility with asynchronous (``async def``) method handlers was
|
||||
added.
|
||||
|
||||
.. method:: setup(request, *args, **kwargs)
|
||||
|
||||
Performs key view initialization prior to :meth:`dispatch`.
|
||||
|
@ -111,6 +122,14 @@ MRO is an acronym for Method Resolution Order.
|
|||
response with the ``Allow`` header containing a list of the view's
|
||||
allowed HTTP method names.
|
||||
|
||||
If the other HTTP methods handlers on the class are asynchronous
|
||||
(``async def``) then the response will be wrapped in a coroutine
|
||||
function for use with ``await``.
|
||||
|
||||
.. versionchanged:: 4.1
|
||||
|
||||
Compatibility with classes defining asynchronous (``async def``)
|
||||
method handlers was added.
|
||||
|
||||
``TemplateView``
|
||||
================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue