... セスできます。 このレジストリは apps と呼ばれ、 django.apps で利用できます: >>> from django.apps import apps >>> apps . get_app_config ( "admin" ) . verbose_na ... ンには、モデル、ビュー、テンプレート、テンプレートタグ、静的ファイル、ミドルウェアなどが含まれます。これらは一般に INSTALLED_APPS 設定で有効になり、それ以外では URLconf、 MIDDLEWARE 設定、テンプレート継承などの仕組みから使われます。 Django のアプリケー ... 。 プロジェクトパッケージがアプリケーションとみなされず、モデルなどを持てないといった制限はありません (その場合は INSTALLED_APPS に設定を追加する必要があります。)。 アプリケーションを設定する ¶ アプリケーションを設定するためには、アプリケーション内に ... ... セスできます。 このレジストリは apps と呼ばれ、 django.apps で利用できます: >>> from django.apps import apps >>> apps . get_app_config ( "admin" ) . verbose_na ... ンには、モデル、ビュー、テンプレート、テンプレートタグ、静的ファイル、ミドルウェアなどが含まれます。これらは一般に INSTALLED_APPS 設定で有効になり、それ以外では URLconf、 MIDDLEWARE 設定、テンプレート継承などの仕組みから使われます。 Django のアプリケー ... 。 プロジェクトパッケージがアプリケーションとみなされず、モデルなどを持てないといった制限はありません (その場合は INSTALLED_APPS に設定を追加する必要があります。)。 アプリケーションを設定する ¶ アプリケーションを設定するためには、アプリケーション内に ... ... tle = "Science Weekly" ) >>> p3 . save () Article を一つ作ります: >>> a1 = Article ( headline = "Django lets you build web apps easily" ) 保存するまでは Publication と関連付けることはできません: >>> a1 . publications . add ( p1 ) Traceback (most rece ... nt call last): ... ValueError : "<Article: Django lets you build web apps easily>" needs to have a value for field "id" before this many-to-many relationship can be used. 保存しましょう! >>> a1 . ... l () <QuerySet [<Article: NASA uses Python>]> >>> p1 . article_set . all () <QuerySet [<Article: Django lets you build web apps easily>, <Article: NASA uses Python>]> >>> Publication . objects . get ( id = 4 ) . article_set . all () <QuerySet [<Artic ... ... tle = "Science Weekly" ) >>> p3 . save () Article を一つ作ります: >>> a1 = Article ( headline = "Django lets you build web apps easily" ) 保存するまでは Publication と関連付けることはできません: >>> a1 . publications . add ( p1 ) Traceback (most rece ... nt call last): ... ValueError : "<Article: Django lets you build web apps easily>" needs to have a value for field "id" before this many-to-many relationship can be used. 保存しましょう! >>> a1 . ... l () <QuerySet [<Article: NASA uses Python>]> >>> p1 . article_set . all () <QuerySet [<Article: Django lets you build web apps easily>, <Article: NASA uses Python>]> >>> Publication . objects . get ( id = 4 ) . article_set . all () <QuerySet [<Artic ... ... tor.connection.alias 属性を見て、データベース接続のエイリアスを確認します: from django.db import migrations def forwards ( apps , schema_editor ): if schema_editor . connection . alias != "default" : return # Your migration code goes here class Migra ... _db" ] return True これをマイグレーションに利用するには、次のようにします: from django.db import migrations def forwards ( apps , schema_editor ): # Your migration code goes here ... class Migration ( migrations . Migration ): dependencies = [ # Depe ... uuid_values.py ¶ # Generated by Django A.B on YYYY-MM-DD HH:MM from django.db import migrations import uuid def gen_uuid ( apps , schema_editor ): MyModel = apps . get_model ( "myapp" , "MyModel" ) for row in MyModel . objects . all (): row . uuid = ... ... tor.connection.alias 属性を見て、データベース接続のエイリアスを確認します: from django.db import migrations def forwards ( apps , schema_editor ): if schema_editor . connection . alias != "default" : return # Your migration code goes here class Migra ... _db" ] return True これをマイグレーションに利用するには、次のようにします: from django.db import migrations def forwards ( apps , schema_editor ): # Your migration code goes here ... class Migration ( migrations . Migration ): dependencies = [ # Depe ... uuid_values.py ¶ # Generated by Django A.B on YYYY-MM-DD HH:MM from django.db import migrations import uuid def gen_uuid ( apps , schema_editor ): MyModel = apps . get_model ( "myapp" , "MyModel" ) for row in MyModel . objects . all (): row . uuid = ... ... uld change it as soon as possible (nothing more than renaming is required). initial_data fixtures are no longer loaded for apps with migrations; if you want to load initial data for an app, we suggest you create a migration for your application and d ... efine 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 longer emulate rollbacks on non-transactional databases or inside Transacti ... onTestCase unless specifically requested . It is not advised to have apps without migrations depend on (have a ForeignKey or ManyToManyField to) apps with migrations. App-loading refactor ¶ Histor ... ... ised every time two models clashed in the app registry. ( #23621 ). Prevented flush from loading initial data for migrated apps ( #23699 ). Fixed a makemessages regression in 1.7.1 when STATIC_ROOT has the default None value ( #23717 ). Added GeoDjan ... timize parameter ( #23799 ). Made RenameModel reversible ( #22248 ) Avoided unnecessary rollbacks of migrations from other apps when migrating backwards ( #23410 ). Fixed a rare query error when using deeply nested subqueries ( #23605 ). Fixed a cras ... n crash when adding order_with_respect_to to a table with existing rows ( #23983 ). Restored the pre_migrate signal if all apps have migrations ( #23975 ). Made admin system checks run for custom AdminSite s ( #23497 ). Ensured the app registry is fu ... ... uld change it as soon as possible (nothing more than renaming is required). initial_data fixtures are no longer loaded for apps with migrations; if you want to load initial data for an app, we suggest you create a migration for your application and d ... efine 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 longer emulate rollbacks on non-transactional databases or inside Transacti ... onTestCase unless specifically requested . It is not advised to have apps without migrations depend on (have a ForeignKey or ManyToManyField to) apps with migrations. App-loading refactor ¶ Histor ... ... ised every time two models clashed in the app registry. ( #23621 ). Prevented flush from loading initial data for migrated apps ( #23699 ). Fixed a makemessages regression in 1.7.1 when STATIC_ROOT has the default None value ( #23717 ). Added GeoDjan ... timize parameter ( #23799 ). Made RenameModel reversible ( #22248 ) Avoided unnecessary rollbacks of migrations from other apps when migrating backwards ( #23410 ). Fixed a rare query error when using deeply nested subqueries ( #23605 ). Fixed a cras ... n crash when adding order_with_respect_to to a table with existing rows ( #23983 ). Restored the pre_migrate signal if all apps have migrations ( #23975 ). Made admin system checks run for custom AdminSite s ( #23497 ). Ensured the app registry is fu ... 2026年10月08日