... ) with no arguments is deprecated, and support for it will be removed in Django 2028. Specify the fields to fetch instead. prefetch_related() prefetch_related ( * lookups ) Returns a QuerySet that will automatically retrieve the given lookups, each in on ... e extra batch query. Prefetching is a way to optimize database access when you know you'll be accessing related objects later, so you can avoid triggeri ... を避けるため、 select_related を適用できるのは単一値のリレーション、つまり外部キーと一対一の関係に制限されています。 一方、 prefetch_related はリレーションごとに個別のルックアップを行い、Pythonで「結合」を行います。これにより、 select_related でサポートさ ... ... opulated ( #28066 ). Fixed layout of ReadOnlyPasswordHashWidget (used in the admin's user change page) ( #28097 ). Allowed prefetch calls on managers with custom ModelIterable subclasses ( #28096 ). Fixed change password link in the contrib.auth admin fo ... 66 ). Corrected the return type of ArrayField(CITextField()) values retrieved from the database ( #28161 ). Fixed QuerySet.prefetch_related() crash when fetching relations in nested Prefetch objects ( #27554 ). Prevented hiding GDAL errors if it's not in ... ... our models with a custom manager . Using this fetch mode is easier than declaring fields to fetch with select_related() or prefetch_related() , especially when it's hard to predict which fields will be accessed. QuerySet.select_related() や prefetch_rela ... ted() を使用する When the FETCH_PEERS fetch mode is not appropriate or efficient enough, use select_related() and prefetch_related() . Understand their documentation thoroughly and apply them where needed. It may be useful to apply these methods ... manager is and is not used; for example, related object access uses the base manager rather than the default manager. Use prefetch_related_objects() Where prefetch_related would be useful after the queryset has been evaluated, use prefetch_related_objec ... ... t on the admin change page. The display routine of this widget was flawed and allowed for XSS. バグ修正 Fixed a crash with prefetch_related() (#19607) as well as some pickle regressions with prefetch_related (#20157 and #20257). Fixed a regression in dja ... ... eck_password() メソッドにより、ユーザーパスワードの非同期チェックが可能になりました。 django.contrib.contenttypes QuerySet.prefetch_related() が、不均一な (non-homogeneous) 結果のセットを含む GenericForeignKey のプリフェッチをサポートするようになりました ... するショートカット aget_object_or_404() と aget_list_or_404() が追加されました。 モデルインスタンスの先読みを非同期的に行う aprefetch_related_objects() 関数が追加されました。 QuerySet.aiterator() が以前の prefetch_related() 呼び出しをサポートするようになり ... わりに lookup_cast() を実装すべきです。 django.db.models.enums.ChoicesMeta メタクラスは ChoicesType に名前が変更されました。 Prefetch.get_current_queryset() メソッドは非推奨になりました。 関係マネージャーとディスクリプタの get_prefetch_queryset() メソッドは ... ... eries. The batch query makes this mode a lot more efficient than FETCH_ONE and is similar to an on-demand call to QuerySet.prefetch_related() or prefetch_related_objects() . Using FETCH_PEERS can reduce most cases of the "N+1 queries problem" to two quer ... ... ine [ソース] GenericInlineModelAdmin のサブクラスで、それぞれスタックレイアウトと表形式のレイアウトを持っています。 GenericPrefetch() class GenericPrefetch ( lookup , querysets , to_attr = None ) [ソース] このルックアップは Prefetch() に類似しており、 Ge ... リセットのリストを受け入れます。これは、結果が均質でない GenericForeignKey に便利です。 >>> from django.contrib.contenttypes.prefetch import GenericPrefetch >>> bookmark = Bookmark . objects . create ( url = "https://www.djangoproject.com/" ) >>> animal = ... "great" , content_object = bookmark ) >>> TaggedItem . objects . create ( tag = "awesome" , content_object = animal ) >>> prefetch = GenericPrefetch ( ... "content_object" , [ Bookmark . objects . all (), Animal . objects . only ( "name" )] ... ) >>> Ta ... ... form system checks, you use the check management command. This command replaces the older validate management command. New Prefetch object for advanced prefetch_related operations. The new Prefetch object allows customizing prefetch operations. You can s ... pecify the QuerySet used to traverse a given relation or customize the storage location of prefetch results. This enables things like filtering prefetched relations, calling select_related() from a prefetched relation, or ... prefetching the same relation multiple times with different querysets. See prefetch_related() for more details. Admin shortcuts support time zones The "today" and "now" shortcuts next to date and time input ... ... is removed. Support for cx_Oracle is removed. The ChoicesMeta alias to django.db.models.enums.ChoicesType is removed. The Prefetch.get_current_queryset() method is removed. The get_prefetch_queryset() method of related managers and descriptors is remove ... d. get_prefetcher() and prefetch_related_objects() no longer fall back to get_prefetch_queryset() . See 5.1 で非推奨となった機能 for detai ... ... ts.get_format() , now only allows accessing the date/time formatting settings. バグ修正 Fixed a data loss possibility with Prefetch if to_attr is set to a ManyToManyField ( #25693 ). ... 2026年10月08日