... ps import apps >>> apps . get_app_config ( "admin" ) . verbose_name 'Administration' プロジェクトとアプリケーション プロジェクト (project ... ンには、モデル、ビュー、テンプレート、テンプレートタグ、静的ファイル、ミドルウェアなどが含まれます。これらは一般に INSTALLED_APPS 設定で有効になり、それ以外では URLconf、 MIDDLEWARE 設定、テンプレート継承などの仕組みから使われます。 Django のアプリケー ... 。 プロジェクトパッケージがアプリケーションとみなされず、モデルなどを持てないといった制限はありません (その場合は INSTALLED_APPS に設定を追加する必要があります。)。 アプリケーションを設定する アプリケーションを設定するためには、アプリケーション内に ap ... ... 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 ... e_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 Historic ... ... 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 ... ... y312-postgres Running the JavaScript tests Django includes a set of JavaScript unit tests for functions in certain contrib apps. The JavaScript tests aren't run by default using tox because they require Node.js to be installed and aren't necessary fo ... numbers. Missing coverage should be considered a warning rather than a blocker and should be evaluated in context. Contrib apps Tests for contrib apps can be found in the tests/ directory, typically under <app_name>_tests . For example, tests for con ... S environment variable for this purpose. Tips for writing tests Isolating model registration To avoid polluting the global apps registry and prevent unnecessary table creation, models defined in a test method should be bound to a temporary Apps insta ... ... ださい。 mysite/settings.py を編集する際、 TIME_ZONE に自分のタイムゾーンも設定します。 同じく、ファイル先頭にある INSTALLED_APPS に注意してください。これはこのDjangoインスタンスの中で有効化されているすべてのDjangoアプリケーションの名前を保持しています ... すし、また、他の開発者が彼らのプロジェクトで使用するためにパッケージして配布することもできます。 デフォルトでは、 INSTALLED_APPS には以下のアプリケーションが入っています。 django.contrib.admin - 管理(admin)サイト。まもなく使います django.contrib.aut ... 。以下のコマンドを実行してください: / $ python manage.py migrate ...\> py manage.py migrate migrate コマンドは INSTALLED_APPS の設定を参照するとともに、 mysite/settings.py ファイルのデータベース設定に従って必要なすべてのデータベースのテーブルを作成 ... ... いるはずです: djangotutorial/ manage.py mysite/ __init__.py settings.py urls.py asgi.py wsgi.py polls/ __init__.py admin.py apps.py migrations/ __init__.py 0001_initial.py models.py static/ polls/ images/ background.png style.css templates/ polls/ det ... んでいます。 アプリケーションラベル (すなわち、アプリケーションパッケージへのパス(ドット区切り)の最後の部分) は INSTALLED_APPS の中で 必ず ユニークでなければなりません。 auth 、 admin 、 messages のようなDjango contrib packages と同じラベルを使うこと ... けてください。 polls ディレクトリを django-polls ディレクトリに移動し、名前を django_polls に変更します。 Edit django_polls/apps.py so that name refers to the new module name, add label to give a short name for the app, and set default_auto_field to e ... ... 検索は式をもとにして結果を返し、現在の類似度のしきい値よりも類似度測定値が高い結果を返します。 これを使うには、 INSTALLED_APPS に 'django.contrib.postgres' を追加し、 PostgreSQL 上で pg_trgm extension を有効にしてください。 TrigramExtension というマ ... 語ルックアップは式を受け取り、現在の類似度閾値よりも大きい単語類似性測定値を持つ結果を返します。 これを使うには、 INSTALLED_APPS に 'django.contrib.postgres' を追加し、 PostgreSQL 上で pg_trgm extension を有効にしてください。 TrigramExtension というマ ... milar trigram_word_similar と似ていますが、範囲の境界を単語の境界に一致させることを強制します。 これを使うには、 INSTALLED_APPS に 'django.contrib.postgres' を追加し、 PostgreSQL 上で pg_trgm extension を有効にしてください。 TrigramExtension というマ ... ... irmation page's summary counts of related objects ( #25883 ). Added from __future__ import unicode_literals to the default apps.py created by startapp on Python 2 ( #25909 ). Add this line to your own apps.py files created using Django 1.9 if you wan ... not in Django's default language list ( LANGUAGES ) ( #25915 ). Avoided hiding some exceptions, like an invalid INSTALLED_APPS setting, behind AppRegistryNotReady when starting runserver ( #25510 ). This regression appeared in 1.8.5 as a side effect ... 2026年10月08日