... ップを実現できます。 たとえば、次のようにしてタグ付けシステムに使用できます: from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.models import ContentType from django.db import models class TaggedItem ( models . Model ... ForeignKey ( ContentType , on_delete = models . CASCADE ) object_id = models . PositiveBigIntegerField () content_object = GenericForeignKey ( "content_type" , "object_id" ) def __str__ ( self ): return self . tag class Meta : indexes = [ models . Index ( fields ... Key を使用する場合、タグを格納する単一のモデルを選択する必要があります。contenttypes アプリケーションは特別なフィールド型( GenericForeignKey ) を提供し、これにより、リレーションシップを任意のモデルと設定できます。 class GenericForeignKey [ソース] GenericForeignKe ... ... Fixed incorrect foreign key constraint name for models with quoted db_table ( #28876 ). Fixed a regression in caching of a GenericForeignKey when the referenced model instance uses more than one level of multi-table inheritance ( #28856 ). ... ... lookups for CICharField , CIEmailField , and CITextField use a citext cast ( #28702 ). Fixed a regression in caching of a GenericForeignKey when the referenced model instance uses multi-table inheritance ( #28856 ). Fixed "Cannot change column 'x': used in a for ... ... foreign and primary key ( #24951 ). Fixed AssertionError in some complex queries ( #24525 ). Fixed a migrations crash with GenericForeignKey ( #25040 ). Made translation.override() clear the overridden language when a translation isn't initially active ( #25295 ) ... ... Fixed incorrect foreign key constraint name for models with quoted db_table ( #28876 ). Fixed a regression in caching of a GenericForeignKey when the referenced model instance uses more than one level of multi-table inheritance ( #28856 ). GeometryField=None の場 ... ... 下のチェックは GenericInlineModelAdmin のインラインとして登録された ModelAdmin に対して行われます。 admin.E301 : <model> に GenericForeignKey がありません。 admin.E302 : 'ct_field' は <label> を参照していますが、これは <model> 上のフィールドではありません。 admin. ... E303 : 'ct_fk_field' は <label> を参照していますが、これは <model> 上のフィールドではありません。 admin.E304 : <model> の GenericForeignKey が、コンテンツタイプのフィールド <field name> とオブジェクトIDのフィールド <field name> を使用していません。 AdminSite デフ ... の前に django.contrib.auth.middleware.AuthenticationMiddleware をMIDDLEWAREで定義する必要があります。 contenttypes モデルに GenericForeignKey または GenericRelation が含まれる場合、以下のチェックが行われます: contenttypes.E001 : GenericForeignKey オブジェクトの ID ... ... isplay() が正しく動かなくなる Django 2.2.7 のリグレッションを修正しました ( #31124 )。 カスタム ContentType 外部キーを持つ GenericForeignKey に対する``QuerySet.prefetch_related()`` がクラッシュする Django 3.0 のリグレッションを修正しました ( #31190 )。 ... ... ions support the power operator ( ** ). The remove() and clear() methods of the related managers created by ForeignKey and GenericForeignKey now accept the bulk keyword argument to control whether or not to perform operations in bulk (i.e. using QuerySet.update() ... ) and clear() methods of related managers The remove() and clear() methods of the related managers created by ForeignKey , GenericForeignKey , and ManyToManyField suffered from a number of issues. Some operations ran multiple data modifying queries without wrappi ... more. You can use the bulk=False keyword argument to revert to the previous behavior. The remove() and clear() methods for GenericForeignKey related managers now perform bulk delete. The Model.delete() method isn't called on each instance anymore. You can use the ... ... ました ( #34539 )。 Django 4.2 におけるリグレッションを修正しました。これにより、 QuerySet.defer() に ManyToManyField または GenericForeignKey の参照を渡すとクラッシュする問題が解消されます。これは、以前のバージョンでは許可されていましたが、実際には何も行われない操 ... ... views.password_reset() view accepts an extra_email_context parameter. django.contrib.contenttypes order_with_respect_to が GenericForeignKey とともに使用できるようになりました。 django.contrib.gis すべての GeoQuerySet メソッドが廃止され、 等価なデータベース関数 で ... ort time zones when USE_TZ is True . Added the RelatedManager.set() method to the related managers created by ForeignKey , GenericForeignKey , and ManyToManyField . The add() method on a reverse foreign key now has a bulk parameter to allow executing one query re ... d() method of related managers To improve performance, the add() methods of the related managers created by ForeignKey and GenericForeignKey changed from a series of Model.save() calls to a single QuerySet.update() call. The change means that pre_save and post_sa ... 2026年10月08日