... ost (see パフォーマンス ), and without the ability to have efficient long-running requests. Many parts of Django provide asynchronous APIs, including the ORM , the cache framework, authentication, sessions, and signals. For other code, the sync_to_async() ... ます ( __init__() でも as_view() でもないことに注意)。 注釈 Django uses inspect.iscoroutinefunction to test if your view is asynchronous or not. If you implement your own method of returning a coroutine, ensure you use inspect.markcoroutinefunction so this fu ... スタイプが使えます。 もしこれらを利用したい場合は、代わりに ASGI を使って Django をデプロイする必要があります。 注釈 A fully asynchronous request stack requires async middleware end-to-end. Where a piece of synchronous middleware sits between an ASGI server an ... ... s AsyncPaginator ( object_list , per_page , orphans = 0 , allow_empty_first_page = True , error_messages = None ) [ソース] Asynchronous version of Paginator . AsyncPaginator has the same attributes and signatures as Paginator , with the following exceptions: ... The attribute Paginator.count is supported as an asynchronous method AsyncPaginator.acount() . The attribute Paginator.num_pages is supported as an asynchronous method AsyncPaginator.a ... num_pages() . The attribute Paginator.page_range is supported as an asynchronous method AsyncPaginator.apage_range() . AsyncPaginator has asynchronous versions of the same methods as Paginator , using an ... ... )。各バージョン系列の最新リリースのみを公式にサポートし、最新リリースを使用することを 強く推奨 します。 Django 3.1 の新機能 Asynchronous views and middleware support Django now supports a fully asynchronous request path, including: Asynchronous views Asynchro ... nous middleware Asynchronous tests and test client To get started with async views, you need to declare a view using async def : async def my_view ( re ... quest ): await asyncio . sleep ( 0.5 ) return HttpResponse ( "Hello, async world!" ) All asynchronous features are supported whether you are running under WSGI or ASGI mode. However, there will be performance penalties using ... ... world!" ) 詳細は 非同期のクラスベース・ビュー を参照してください。 非同期の ORM インターフェース QuerySet now provides an asynchronous interface for all data access operations. These are named as-per the existing synchronous operations but with an a prefix, ... for example acreate() , aget() , and so on. The new interface allows you to write asynchronous code without needing to wrap ORM operations in sync_to_async() : async for author in Author . objects . filter ( name__sta ... rst () Note that, at this stage, the underlying database operations remain synchronous, with contributions ongoing to push asynchronous support down into the SQL compiler, and integrate asynchronous database drivers. The new asynchronous queryset interface c ... ... owever. At this stage async support only applies to the outer ASGI application. Internally everything remains synchronous. Asynchronous middleware, views, etc. are not yet supported. You can, however, use ASGI middleware around Django's application, allowing ... with other ASGI frameworks. There is no need to switch your applications over unless you want to start experimenting with asynchronous code, but we have documentation on deploying with ASGI if you want to learn more. Note that as a side-effect of this chang ... e, Django is now aware of asynchronous event loops and will block you calling code marked as "async unsafe" - such as ORM operations - from an asynchronous conte ... ... e ): await pizza_done . asend ( sender = self . __class__ , toppings = toppings , size = size ) ... Whether synchronous or asynchronous, receivers will be correctly adapted to whether send() or asend() is used. Synchronous receivers will be called using sync ... _to_async() when invoked via asend() . Asynchronous receivers will be called using async_to_sync() when invoked via send() . Similar to the case for middleware , there is a s ... send() or asend() call, the receivers are grouped by whether or not they are async before being called. This means that an asynchronous receiver registered before a synchronous receiver may be executed after the synchronous receiver. In addition, async recei ... ... nd the code in the django/tasks/backends/ directory of the Django source. 非同期サポート Django has developing support for asynchronous Task backends. BaseTaskBackend has async variants of all base methods. By convention, the asynchronous versions of all met ... ... or inequality assertJSONEqual() JSON fragment equality 編集した設定 でテストを実行する機能。 Access to the synchronous and asynchronous test clients via the client and async_client attributes. データベースクエリを作る手薄との場合、サブクラス TransactionTestC ... eTestCase. client SimpleTestCase. async_client Every django.test.*TestCase instance has access to Django's synchronous and asynchronous test clients as self.client and self.async_client , respectively. Both clients are recreated for each test, so you don't h ... tuff ( self ): # Here self.client is an instance of MyTestClient... call_some_test_code () The same pattern applies to the asynchronous test client by subclassing AsyncClient and setting async_client_class . フィクスチャのロード TransactionTestCase. fixtures ... ... メソッドを2つのセクションに分けています: Methods that return new querysets : These are the non-blocking ones, and don't have asynchronous versions. You're free to use these in any situation, but understand the constraint of no deferred queries before using def ... No deferred queries Relations are deferred by default. If the blog relation is not prefetched, accessing entry.blog during asynchronous evaluation of a queryset attempts a blocking database query, raising SynchronousOnlyOperation . (A similar limitation appl ... ... 期バージョン : aiterator() Evaluates the QuerySet (by performing the query) and returns an iterator over the results, or an asynchronous iterator if you call its asynchronous version aiterator . A QuerySet typically caches its results internally so that repea ... 2026年10月08日