... lder versions. オーバービュー Django 1.2 introduces several large, important new features, including: Support for multiple database connections in a single Django instance. Model validation inspired by Django's form validation. Vastly improved protection ... rently being developed, and will be announced prior to the release of Django 1.3. Django 1.2 の新機能 Support for multiple databases Django 1.2 adds the ability to use more than one database in your Django project. Queries can be issued at a specific dat ... abase with the using() method on QuerySet objects. Individual objects can be saved to a specific database by providing a using argument when you call save() . Model validation Model instances now have support for validating thei ... ... details on installing the optional test dependencies. Running the tests requires a Django settings module that defines the databases to use. To help you get started, Django provides and uses a sample settings module that uses the SQLite database. See Usi ... ng another settings module to learn how to use a different settings module to run the tests with a different database. Having problems? See トラブルシューティング for some common issues. Running tests using tox Tox is a tool for running tes ... ox -l py3 black blacken-docs flake8> =3.7.0 docs isort> =7.0.0 lint-docs zizmor> =1.19.0 Testing other Python versions and database backends In addition to the default environments, tox supports running unit tests for other versions of Python and other d ... ... 強く推奨 します。 Django 2.2 の新機能 Constraints The new CheckConstraint and UniqueConstraint classes enable adding custom database constraints. Constraints are added to models using the Meta.constraints option. マイナーな機能 django.contrib.admin Added ... elements. The new BTreeIndex , HashIndex and SpGistIndex classes allow creating B-Tree , hash , and SP-GiST indexes in the database. BrinIndex now has the autosummarize parameter. The new search_type parameter of SearchQuery allows searching for a phrase ... operator classes ( Index.opclasses ). Added support for partial indexes ( Index.condition ). Added the NullIf and Reverse database functions, as well as many math database functions . Setting the new ignore_conflicts parameter of QuerySet.bulk_create() ... ... also been improved on all backends. There is a corresponding form field . Query Expressions, Conditional Expressions, and Database Functions Query Expressions allow you to create, customize, and compose complex SQL expressions. This has enabled annotate ... to accept expressions. Conditional Expressions allow you to use if ... elif ... else logic within queries. A collection of database functions is also included with functionality such as Coalesce , Concat , and Substr . TestCase data setup TestCase has be ... en refactored to allow for data initialization at the class level using transactions and savepoints. Database backends which do not support transactions, like MySQL with the MyISAM storage engine, will still be able to run these tes ... ... isting, synchronous code. It should have no noticeable effect on any existing Django projects. JSONField for all supported database backends Django now includes models.JSONField and forms.JSONField that can be used on all supported database backends. Bot ... .JSONField , plus the related form field and transforms, you should adjust to use the new fields, and generate and apply a database migration. For now, the old fields and transforms are left as a reference to the new ones and are deprecated as of this re ... lter now supports negative integers. django.contrib.postgres The new BloomIndex class allows creating bloom indexes in the database. The new BloomExtension migration operation installs the bloom extension to add support for this index. get_FOO_display() ... ... ースを定義する Django でデータベースを使う最初のステップは、利用するデータベースサーバーを Django に教えることです。これは、 DATABASES の設定で行います。この設定は、データベースへのエイリアスです。Django を通してデータベースを参照するためのデータベースエイ ... リアスを、辞書にマッピングします。この辞書の設定の詳細は、 DATABASES ドキュメントで説明しています。 データベースには、選択した任意のエイリアスを付けることができます。しかし、エイリアス defau ... わちデフォルトの PostgreSQL データベースと users という名前の MySQL データベースを定義した settings.py スニペットの例です。 DATABASES = { "default" : { "NAME" : "app_data" , "ENGINE" : "django.db.backends.postgresql" , "USER" : "postgres_user" , "PASSWORD ... ... o.contrib.admin , supports filtering of displayed lists of objects by fields on the corresponding models, including across database-level relationships. This is implemented by passing lookup arguments in the querystring portion of the URL, and options on ... d relations could construct query strings which -- with repeated use of regular-expression lookups supported by the Django database API -- expose sensitive information such as users' password hashes. To remedy this, django.contrib.admin will now validate ... s rule. One of the bugs fixed in Django 1.2.4 involves a set of circumstances whereby a running a test suite on a multiple database configuration could cause the original source database (i.e., the actual production database) to be dropped, causing catas ... ... se user. In older versions, if a password isn't manually specified in the database settings TEST dictionary, a hardcoded password is used. This could allow an attacker with network access to the database s ... , this is at least a cross-site scripting vector, which could be quite serious if developers load a copy of the production database in development or connect to some production services for which there's no development instance, for example. If a project ... ug-toolbar , then the attacker could execute arbitrary SQL, which could be especially bad if the developers connect to the database with a superuser account. settings.ALLOWED_HOSTS is now validated regardless of DEBUG . For convenience, if ALLOWED_HOSTS ... ... t, a separate, backwards-compatible backend, called "mysql_old", has been added to Django. To use this backend, change the DATABASE_ENGINE setting in your Django settings file from this: DATABASE_ENGINE = "mysql" to this: DATABASE_ENGINE = "mysql_old" Ho ... be actively maintained, and it will be removed in a future release of Django. Also, note that some features, like the new DATABASE_OPTIONS setting (see the databases documentation for details), are only available on the "mysql" backend, and will not be ... are not always visible. The effect of this change is that running manage.py reset and similar commands against an existing database may generate SQL with the new form of constraint name, while the database itself contains constraints named in the old for ... ... eates a temporary database user. In older versions, if a password isn't manually specified in the database settings TEST dictionary, a hardcoded pass ... word is used. This could allow an attacker with network access to the database server to connect. This user is usually dropped after the test suite completes, but not when using the manage.py test --ke ... , this is at least a cross-site scripting vector, which could be quite serious if developers load a copy of the production database in development or connect to some production services for which there's no development instance, for example. If a project ... 2026年10月08日