... ュー を参照してください。 非同期の 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__startswith = "A" ): book = await author . books ... . afirst () 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 asyn ... ... migration code goes here class Migration ( migrations . Migration ): dependencies = [ # Dependencies to other migrations ] operations = [ migrations . RunPython ( forwards ), ] You can also provide hints that will be passed to the allow_migrate() method of ... ation code goes here ... class Migration ( migrations . Migration ): dependencies = [ # Dependencies to other migrations ] operations = [ migrations . RunPython ( forwards , hints = { "target_db" : "default" }), ] もし RunPython や RunSQL 操作が 1 つのモデ ... dels import uuid class Migration ( migrations . Migration ): dependencies = [ ( "myapp" , "0005_populate_uuid_values" ), ] operations = [ migrations . AlterField ( model_name = "mymodel" , name = "uuid" , field = models . UUIDField ( default = uuid . uuid4 ... ... が正しい結果を出力しなくなる可能性があることに十分注意してください。 Django が提供するコア機能は全て django.db.migrations.operations モジュールから利用できます。 より入門的な内容に関しては、 トピックスのマイグレーション を参照ください。 スキーマ・オペレー ... う名前の制約を新たな constraint に置き換えます。 特別なオペレーション RunSQL class RunSQL ( sql , reverse_sql = None , state_operations = None , hints = None , elidable = False ) [ソース] データベース上で任意の SQL を実行できるようにします。Django が直接サポ ... %s ;" , [ "Reinhardt" ])], ) reverse_sql が None (デフォルト) の場合、 RunSQL オペレーションは元に戻りません。 引数 state_operations にはプロジェクトのステートから見た SQL と等価となる処理を渡すことができます。たとえば、手動でカラムを作成した場合、マイグレ ... ... ッド) add_stylesheets() (SyndicationFeed のメソッド) add_view() (ModelAdmin のメソッド) AddConstraint (django.db.migrations.operations のクラス) AddConstraintNotValid (django.contrib.postgres.operations のクラス) AddField (django.db.migrations.operations の ... クラス) AddIndex (django.db.migrations.operations のクラス) AddIndexConcurrently (django.contrib.postgres.operations のクラス) ADDITION (OperationCategory の属性) addslashe ... gether() (BaseDatabaseSchemaEditor のメソッド) ALTERATION (OperationCategory の属性) AlterConstraint (django.db.migrations.operations のクラス) AlterField (django.db.migrations.operations のクラス) AlterIndexTogether (django.db.migrations.operations のクラ ... ... べあげ、やり直さなければならないということです (過去の時点にロールバックすることは不可能ということです)。 MySQL 8.0 では DDL operations のパフォーマンスが大幅に強化され、より効率的になり、テーブルの完全な再構築の必要性が減りました。しかし、ロックや中断が完全 ... マイグレーションファイルが生成されたら、期待通りに変更が行われるように、データベースに適用します: $ python manage.py migrate Operations to perform: Apply all migrations: books Running migrations: Applying books.0003_auto... OK マイグレーションを適用したら、マ ... import migrations , models class Migration ( migrations . Migration ): dependencies = [( "migrations" , "0001_initial" )] operations = [ migrations . DeleteModel ( "Tribble" ), migrations . AddField ( "Author" , "rating" , models . IntegerField ( default ... ... するために、 HStoreExtension オペレーションを含むマイグレーションを追加してください。たとえば: from django.contrib.postgres.operations import HStoreExtension class Migration ( migrations . Migration ): ... operations = [ HStoreExtension (), ... ] オペレーシ ... きます。 例えば、ドイツ語の電話帳順に並べ替えるための照合順序を作成するには、次のようにします: from django.contrib.postgres.operations import CreateCollation class Migration ( migrations . Migration ): ... operations = [ CreateCollation ( "case_insensitive" ... ... れます。プロジェクトでの代替方法として、マイグレーションオペレーションを使用する方法があります: from django.contrib.postgres.operations import CreateExtension from django.db import migrations class Migration ( migrations . Migration ): operations = [ CreateE ... ... data for an app, we suggest you create a migration for your application and define a RunPython or RunSQL operation in the operations section of the migration. Test rollback behavior is different for apps with migrations; in particular, Django will no long ... nt 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 specify the QuerySet used to traverse a given rel ... gers 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() ). Defaults to True . It is now possible to use None as a query value for the iexact ... ... ght or left hand side of an expression is a key transform ( #30826 ). Prevented migrate --plan from showing that RunPython operations are irreversible when reverse_code callables don't have docstrings or when showing a forward migration plan ( #30870 ). Fi ... ... ction of the current timezone, conversion of datetime instances to the current timezone in forms and templates, as well as operations on aware datetimes in UTC are unaffected. However, if you are working with non-UTC time zones, and using the pytz normaliz ... ド API このセクションでは、サードパーティのデータベースバックエンドで必要になる可能性のある変更について説明します。 DatabaseOperations.year_lookup_bounds_for_date_field() and year_lookup_bounds_for_datetime_field() methods now take the optional iso_year arg ... igrations autodetector changes The migrations autodetector now uses model states instead of model classes. Also, migration operations for ForeignKey and ManyToManyField fields no longer specify attributes which were not passed to the fields during initiali ... 2026年10月08日