---
title: "Django 1.11 リリースノート"
version: 6.1
locale: ja
source: https://docs.djangoproject.com/ja/6.1/releases/1.11/
canonical: https://djangodocs.dev/ja/6.1/releases/1.11/
---
# Django 1.11 リリースノート

*April 4, 2017*

Django 1.11 へようこそ！

このリリースノートでは、Django 1.10 および過去のバージョンからアップグレードする際に知っておくべきいくつかの [後方互換性のない変更](#backwards-incompatible-1-11) に加え、[新機能](#whats-new-1-11) を説明しています。[いくつかの機能に対する廃止プロセスを開始しました](#deprecated-features-1-11)。

既存のプロジェクトをアップデートするときは、 [Django の新しいバージョンへの更新](/ja/6.1/howto/upgrade-version/) ガイドに従ってください。

Django 1.11 は、[長期サポートリリース](/ja/6.1/internals/release-process/#term-Long-term-support-release) として指定されています。リリースから最低3年間はセキュリティアップデートを受けます。以前の LTS である Django 1.8 に対するサポートは2018年4月に終了します。

## Python バージョン間の互換性

Django 1.11 の動作には Python 2.7, 3.4, 3.5, 3.6, 3.7 のいずれかが必要です。各バージョン系列の最終リリースの Python を使用することを **強く推奨** し、公式には最終リリースしかサポートしません。

The Django 1.11.x series is the last to support Python 2. The next major
release, Django 2.0, will only support Python 3.4+.

## 廃止予定警告はデフォルトでは表示されなくなりました。

Django の過去のバージョンとは異なり、Django 自体の廃止予定警告はデフォルトでは非表示となりました。これは Python のデフォルト動作と同じです。

これによって、サードパーティアプリが、廃止予定警告を回避するためのコードを追加することなく、Django 1.11 LTS と Django 1.8 LTS の両方をサポートできるようになります。

Django 2.0 のリリースを控えているため、サードパーティアプリの開発者は 1.11 以前のバージョンの Django へのサポートを終えるよう推奨します。このとき、`python -Wd` を使ったパッケージテストを実行できるようにして、廃止予定警告を表示します。廃止予定警告を作り終えたら、アプリケーションは Django 2.0 と互換可能となります。

## Django 1.11 の新機能

### クラスベースモデルのインデックス

新しい [`django.db.models.indexes`](/ja/6.1/ref/models/indexes/#module-django.db.models.indexes) モジュールはデータベースインデックスの作成を簡単にするクラスを含んでいます。インデックスは [`Meta.indexes`](/ja/6.1/ref/models/options/#django.db.models.Options.indexes) オプションを使ってモデルに追加されます。

The [`Index`](/ja/6.1/ref/models/indexes/#django.db.models.Index) class creates a b-tree index, as if you
used [`db_index`](/ja/6.1/ref/models/fields/#django.db.models.Field.db_index) on the model field or
`index_together` on the model `Meta` class. It can be subclassed to support
different index types, such as
[`GinIndex`](/ja/6.1/ref/contrib/postgres/indexes/#django.contrib.postgres.indexes.GinIndex). It also allows defining the
order (ASC/DESC) for the columns of the index.

### テンプレートベースのウィジェット表示

ウィジェットのカスタマイズを簡単にするため、フォームウィジェットの表示が Python 内ではなくテンプレートシステムを使って行われるようになりました。[フォームレンダリング API](/ja/6.1/ref/forms/renderers/) を参照してください。

いくつかの [後方互換性のない変更](#template-widget-incompatibilities-1-11) のため、実装済みのカスタムウィジェットを調整する必要があるかもしれません。

### `Subquery` 表現

新たな [`Subquery`](/ja/6.1/ref/models/expressions/#django.db.models.Subquery) と [`Exists`](/ja/6.1/ref/models/expressions/#django.db.models.Exists) データベース表現によって、明示的なサブクエリを作成することができます。サブクエリは、[`OuterRef`](/ja/6.1/ref/models/expressions/#django.db.models.OuterRef) を使って外部のクエリセットからフィールドを参照することができます。

### マイナーな機能

#### [`django.contrib.admin`](/ja/6.1/ref/contrib/admin/#module-django.contrib.admin)

- [`ModelAdmin.date_hierarchy`](/ja/6.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.date_hierarchy) はリレーションシップを通じてフィールドを参照できるようになりました。
- 新たな [`ModelAdmin.get_exclude()`](/ja/6.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_exclude) フックによって、リクエストやモデルインスタンスに基づいた除外フィールドを指定できます。
- `popup_response.html` テンプレートが、アプリケーションごと、モデルごと、もしくはセッティング [`ModelAdmin.popup_response_template`](/ja/6.1/ref/contrib/admin/#django.contrib.admin.ModelAdmin.popup_response_template) 属性によってオーバーライドできるようになりました。

#### [`django.contrib.auth`](/ja/6.1/topics/auth/#module-django.contrib.auth)

- PBKDF2 パスワードハッシュに対するデフォルトのイテレーション回数が 20% 増加しました。
- [`LoginView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.LoginView) と [`LogoutView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.LogoutView) クラスベースビューが、廃止される `login()` と `logout()` 関数ベースビューの後継となりました。
- [`PasswordChangeView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordChangeView)、[`PasswordChangeDoneView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordChangeDoneView)、[`PasswordResetView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetView)、[`PasswordResetDoneView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetDoneView)、[`PasswordResetConfirmView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetConfirmView)、[`PasswordResetCompleteView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetCompleteView) クラスベースビューが、廃止される `password_change()`、`password_change_done()`、`password_reset()`、`password_reset_done()`、`password_reset_confirm()`、`password_reset_complete()` 関数ビューの後継となりました。
- [`PasswordResetConfirmView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetConfirmView) の新しい `post_reset_login` 属性によって、パスワードリセットが成功した後に自動的にログインできるようになりました。複数の `AUTHENTICATION_BACKENDS` を設定している場合、`post_reset_login_backend` 属性を使ってどれを使うか選択してください。
- HTTP リファラヘッダを通じてパスワードリセットトークンが漏れる可能性を防ぐため (たとえば、リセットページが他のドメインにホストされた CSS や JavaScript への参照を含む場合)、[`PasswordResetConfirmView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetConfirmView) (廃止される `password_reset_confirm()` 関数ベースビューではありません) セッションにトークンを保持し、自身にリダイレクトして URL 内のトークンなしでユーザへのパスワード変更フォームを送信します。
- [`update_session_auth_hash()`](/ja/6.1/topics/auth/default/#django.contrib.auth.update_session_auth_hash) がセッションキーをローテーションさせるようになり、パスワード変更が盗聴されたセッションクッキーを無効化できるようになりました。
- [`LoginView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.LoginView) と [`LogoutView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.LogoutView) の新しい `success_url_allowed_hosts` 属性によって、ログインおよびログアウト後のリダイレクトに対して安全なホストのセットを指定できるようになりました。
- パスワードのバリデータ `help_text` が [`UserCreationForm`](/ja/6.1/topics/auth/default/#django.contrib.auth.forms.UserCreationForm) に追加されました。
- `HttpRequest` が [`authenticate()`](/ja/6.1/topics/auth/default/#django.contrib.auth.authenticate) に渡されるようになりました。これは、`request` 属性を受け入れる場合にリクエストを認証バックエンドに順番に渡します。
- [`user_login_failed()`](/ja/6.1/ref/contrib/auth/#django.contrib.auth.signals.user_login_failed) シグナルが `request` 属性を受け取るようになりました。
- [`PasswordResetForm`](/ja/6.1/topics/auth/default/#django.contrib.auth.forms.PasswordResetForm) は `'email'` ではない名前の E メールフィールドを使うカスタムユーザーモデルをサポートします。[`CustomUser.EMAIL_FIELD`](/ja/6.1/topics/auth/customizing/#django.contrib.auth.models.CustomUser.EMAIL_FIELD) をフィールドの名前にセットしてください。
- モデルを定義するモジュール内においても、[`get_user_model()`](/ja/6.1/topics/auth/customizing/#django.contrib.auth.get_user_model) をインポート時に呼ぶことができるようになりました。

#### [`django.contrib.contenttypes`](/ja/6.1/ref/contrib/contenttypes/#module-django.contrib.contenttypes)

- When stale content types are detected in the
  [`remove_stale_contenttypes`](/ja/6.1/ref/django-admin/#django-admin-remove_stale_contenttypes) command, there's now a list of related
  objects such as `auth.Permission`s that will also be deleted. Previously,
  only the content types were listed (and this prompt was after `migrate`
  rather than in a separate command).

#### [`django.contrib.gis`](/ja/6.1/ref/contrib/gis/#module-django.contrib.gis)

- 新たな [`GEOSGeometry.from_gml()`](/ja/6.1/ref/contrib/gis/geos/#django.contrib.gis.geos.GEOSGeometry.from_gml) と [`OGRGeometry.from_gml()`](/ja/6.1/ref/contrib/gis/gdal/#django.contrib.gis.gdal.OGRGeometry.from_gml) メソッドによって、GML から幾何学的配置を作成できるようになりました。
- Added support for the [`dwithin`](/ja/6.1/ref/contrib/gis/geoquerysets/#std-fieldlookup-dwithin) lookup on SpatiaLite.
- The [`Area`](/ja/6.1/ref/contrib/gis/functions/#django.contrib.gis.db.models.functions.Area) function,
  [`Distance`](/ja/6.1/ref/contrib/gis/functions/#django.contrib.gis.db.models.functions.Distance) function, and
  distance lookups now work with geodetic coordinates on SpatiaLite.
- The OpenLayers-based form widgets now use `OpenLayers.js` from
  `https://cdnjs.cloudflare.com` which is more suitable for production use
  than the old `https://openlayers.org/` source. They are also updated to use
  OpenLayers 3.
- PostGIS migrations can now change field dimensions.
- Added the ability to pass the `size`, `shape`, and `offset` parameters
  when creating [`GDALRaster`](/ja/6.1/ref/contrib/gis/gdal/#django.contrib.gis.gdal.GDALRaster) objects.
- Added SpatiaLite support for the
  [`IsValid`](/ja/6.1/ref/contrib/gis/functions/#django.contrib.gis.db.models.functions.IsValid) function,
  [`MakeValid`](/ja/6.1/ref/contrib/gis/functions/#django.contrib.gis.db.models.functions.MakeValid) function, and
  [`isvalid`](/ja/6.1/ref/contrib/gis/geoquerysets/#std-fieldlookup-isvalid) lookup.
- Added Oracle support for the
  [`AsGML`](/ja/6.1/ref/contrib/gis/functions/#django.contrib.gis.db.models.functions.AsGML) function,
  [`BoundingCircle`](/ja/6.1/ref/contrib/gis/functions/#django.contrib.gis.db.models.functions.BoundingCircle) function,
  [`IsValid`](/ja/6.1/ref/contrib/gis/functions/#django.contrib.gis.db.models.functions.IsValid) function, and
  [`isvalid`](/ja/6.1/ref/contrib/gis/geoquerysets/#std-fieldlookup-isvalid) lookup.

#### [`django.contrib.postgres`](/ja/6.1/ref/contrib/postgres/#module-django.contrib.postgres)

- The new `distinct` argument for
  [`StringAgg`](/ja/6.1/ref/contrib/postgres/aggregates/#django.contrib.postgres.aggregates.StringAgg) determines if
  concatenated values will be distinct.
- The new [`GinIndex`](/ja/6.1/ref/contrib/postgres/indexes/#django.contrib.postgres.indexes.GinIndex) and
  [`BrinIndex`](/ja/6.1/ref/contrib/postgres/indexes/#django.contrib.postgres.indexes.BrinIndex) classes allow
  creating `GIN` and `BRIN` indexes in the database.
- `django.contrib.postgres.fields.JSONField` accepts a new `encoder`
  parameter to specify a custom class to encode data types not supported by the
  standard encoder.
- 新たな `CIText` ミックスインと [`CITextExtension`](/ja/6.1/ref/contrib/postgres/operations/#django.contrib.postgres.operations.CITextExtension) によるマイグレーション操作により、 PostgreSQL の `citext` 拡張を大文字小文字の区別なく検索できるようになりました。 ここでは、 `CICharField` 、 `CIEmailField` 、 `CITextField` の3つのフィールドが追加されます。
- The new [`JSONBAgg`](/ja/6.1/ref/contrib/postgres/aggregates/#django.contrib.postgres.aggregates.JSONBAgg) allows
  aggregating values as a JSON array.
- The [`HStoreField`](/ja/6.1/ref/contrib/postgres/fields/#django.contrib.postgres.fields.HStoreField) (model field) and
  [`HStoreField`](/ja/6.1/ref/contrib/postgres/forms/#django.contrib.postgres.forms.HStoreField) (form field) allow
  storing null values.

#### キャッシュ

- Memcached backends now pass the contents of
  [`OPTIONS`](/ja/6.1/ref/settings/#std-setting-CACHES-OPTIONS) as keyword arguments to the client
  constructors, allowing for more advanced control of client behavior. See the
  [cache arguments](/ja/6.1/topics/cache/#cache-arguments) documentation for examples.
- Memcached backends now allow defining multiple servers as a comma-delimited
  string in [`LOCATION`](/ja/6.1/ref/settings/#std-setting-CACHES-LOCATION), for convenience with
  third-party services that use such strings in environment variables.

#### CSRF

- Added the [`CSRF_USE_SESSIONS`](/ja/6.1/ref/settings/#std-setting-CSRF_USE_SESSIONS) setting to allow storing the CSRF
  token in the user's session rather than in a cookie.

#### データベースバックエンド

- Added the `skip_locked` argument to [`QuerySet.select_for_update()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.select_for_update)
  on PostgreSQL 9.5+ and Oracle to execute queries with
  `FOR UPDATE SKIP LOCKED`.
- Added the [`TEST['TEMPLATE']`](/ja/6.1/ref/settings/#std-setting-TEST_TEMPLATE) setting to let
  PostgreSQL users specify a template for creating the test database.
- [`QuerySet.iterator()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.iterator) now uses [server-side cursors](https://www.psycopg.org/docs/usage.html#server-side-cursors) on PostgreSQL.
  This feature transfers some of the worker memory load (used to hold query
  results) to the database and might increase database memory usage.
- Added MySQL support for the `'isolation_level'` option in
  [`OPTIONS`](/ja/6.1/ref/settings/#std-setting-OPTIONS) to allow specifying the [transaction isolation level](/ja/6.1/ref/databases/#mysql-isolation-level). To avoid possible data loss, it's recommended to
  switch from MySQL's default level, repeatable read, to read committed.
- Added support for `cx_Oracle` 5.3.

#### E メール

- [`EMAIL_USE_LOCALTIME`](/ja/6.1/ref/settings/#std-setting-EMAIL_USE_LOCALTIME) 設定が追加され、SMTP 日付ヘッダを UTC ではなくローカルタイムゾーンで送信できるようになりました。
- `EmailMessage.attach()` and `attach_file()` now fall back to MIME type
  `application/octet-stream` when binary content that can't be
  decoded as UTF-8 is specified for a `text/*` attachment.

#### ファイルストレージ

- [`io.TextIOWrapper`](https://docs.python.org/3/library/io.html#io.TextIOWrapper) でラップできるように、[`File`](/ja/6.1/ref/files/file/#django.core.files.File) に `readable()`、 `writable()`、 `seekable()` メソッドが追加されました。

#### フォーム

- The new `empty_value` attribute on [`CharField`](/ja/6.1/ref/forms/fields/#django.forms.CharField),
  [`EmailField`](/ja/6.1/ref/forms/fields/#django.forms.EmailField), [`RegexField`](/ja/6.1/ref/forms/fields/#django.forms.RegexField),
  [`SlugField`](/ja/6.1/ref/forms/fields/#django.forms.SlugField), and [`URLField`](/ja/6.1/ref/forms/fields/#django.forms.URLField) allows
  specifying the Python value to use to represent "empty".
- 新たな [`Form.get_initial_for_field()`](/ja/6.1/ref/forms/api/#django.forms.Form.get_initial_for_field) メソッドは、フォームフィールドに対する初期データを返します。

#### 国際化 (internationalization)

- 数値の書式および [`NUMBER_GROUPING`](/ja/6.1/ref/settings/#std-setting-NUMBER_GROUPING) 設定が単一ではない桁グルーピングをサポートするようになりました。

#### 管理コマンド

- 新たな [`loaddata --exclude`](/ja/6.1/ref/django-admin/#cmdoption-loaddata-exclude) オプションによって、フィクスチャからデータを読み込んでいる間にモデルとアプリケーションを除外することができるようになりました。
- 新たな [`diffsettings --default`](/ja/6.1/ref/django-admin/#cmdoption-diffsettings-default) オプションによって、Django のデフォルトの設定以外の設定モジュールを指定し、対比できるようになりました。
- `app_label`属性が [`showmigrations --plan`](/ja/6.1/ref/django-admin/#cmdoption-showmigrations-plan) アウトプットを制限するようになりました。

#### マイグレーション

- `uuid.UUID` オブジェクトのシリアライズに対するサポートを追加しました。

#### モデル

- [`QuerySet.update_or_create()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.update_or_create) と [`get_or_create()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.get_or_create) の `defaults` 属性で呼び出し可能な値に対するサポートが追加されました。
- [`ImageField`](/ja/6.1/ref/models/fields/#django.db.models.ImageField) now has a default
  [`validate_image_file_extension`](/ja/6.1/ref/validators/#django.core.validators.validate_image_file_extension) validator.
  (This validator moved to the form field in [Django 1.11.2](/ja/6.1/releases/1.11.2/).)
- Added support for time truncation to
  [`Trunc`](/ja/6.1/ref/models/database-functions/#django.db.models.functions.Trunc) functions.
- Added the [`ExtractWeek`](/ja/6.1/ref/models/database-functions/#django.db.models.functions.ExtractWeek) function to
  extract the week from [`DateField`](/ja/6.1/ref/models/fields/#django.db.models.DateField) and
  [`DateTimeField`](/ja/6.1/ref/models/fields/#django.db.models.DateTimeField) and exposed it through the
  [`week`](/ja/6.1/ref/models/querysets/#std-fieldlookup-week) lookup.
- Added the [`TruncTime`](/ja/6.1/ref/models/database-functions/#django.db.models.functions.TruncTime) function to truncate
  [`DateTimeField`](/ja/6.1/ref/models/fields/#django.db.models.DateTimeField) to its time component and exposed it
  through the [`time`](/ja/6.1/ref/models/querysets/#std-fieldlookup-time) lookup.
- [`QuerySet.values()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.values) と [`values_list()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.values_list) の表現へのサポートを追加しました。
- `range` のような複数属性を取るルックアップでのクエリ表現へのサポートを追加しました。
- [`FileField`](/ja/6.1/ref/models/fields/#django.db.models.FileField) で `unique=True` オプションを使用できるようになりました。
- `nulls_first` と `nulls_last` パラメータを [`Expression.asc()`](/ja/6.1/ref/models/expressions/#django.db.models.Expression.asc) と [`desc()`](/ja/6.1/ref/models/expressions/#django.db.models.Expression.desc) に追加し、null 値の順序をコントロールできるようにしました。
- 新たな `F` 表現 `bitleftshift()` と `bitrightshift()` メソッドによって、[ビットワイズシフトオペレーション](/ja/6.1/topics/db/queries/#using-f-expressions-in-filters) ができるようになりました。
- [`QuerySet.union()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.union)、[`intersection()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.intersection)、[`difference()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.difference) を追加しました。

#### Request と Response

- [`QueryDict.fromkeys()`](/ja/6.1/ref/request-response/#django.http.QueryDict.fromkeys) を追加しました。
- [`CommonMiddleware`](/ja/6.1/ref/middleware/#django.middleware.common.CommonMiddleware) が 非ストリーミングレスポンスに対して `Content-Length` レスポンスヘッダをセットするようになりました。
- Added the [`SECURE_HSTS_PRELOAD`](/ja/6.1/ref/settings/#std-setting-SECURE_HSTS_PRELOAD) setting to allow appending the
  `preload` directive to the `Strict-Transport-Security` header.
- [`ConditionalGetMiddleware`](/ja/6.1/ref/middleware/#django.middleware.http.ConditionalGetMiddleware) now adds the
  `ETag` header to responses.

#### シリアライズ (シリアル化)

- The new `django.core.serializers.base.Serializer.stream_class` attribute
  allows subclasses to customize the default stream.
- The encoder used by the [JSON serializer](/ja/6.1/topics/serialization/#serialization-formats-json)
  can now be customized by passing a `cls` keyword argument to the
  `serializers.serialize()` function.
- [`DjangoJSONEncoder`](/ja/6.1/topics/serialization/#django.core.serializers.json.DjangoJSONEncoder) now serializes
  [`timedelta`](https://docs.python.org/3/library/datetime.html#datetime.timedelta) objects (used by
  [`DurationField`](/ja/6.1/ref/models/fields/#django.db.models.DurationField)).

#### テンプレート

- [`mark_safe()`](/ja/6.1/ref/utils/#django.utils.safestring.mark_safe) can now be used as a decorator.
- The [`Jinja2`](/ja/6.1/topics/templates/#django.template.backends.jinja2.Jinja2) template backend now
  supports context processors by setting the `'context_processors'` option in
  [`OPTIONS`](/ja/6.1/ref/settings/#std-setting-TEMPLATES-OPTIONS).
- The [`regroup`](/ja/6.1/ref/templates/builtins/#std-templatetag-regroup) tag now returns `namedtuple`s instead of dictionaries
  so you can unpack the group object directly in a loop, e.g.
  `{% for grouper, list in regrouped %}`.
- Added a [`resetcycle`](/ja/6.1/ref/templates/builtins/#std-templatetag-resetcycle) template tag to allow resetting the sequence of
  the [`cycle`](/ja/6.1/ref/templates/builtins/#std-templatetag-cycle) template tag.
- You can now specify specific directories for a particular
  [`filesystem.Loader`](/ja/6.1/ref/templates/api/#django.template.loaders.filesystem.Loader).

#### テスト

- Added [`DiscoverRunner.get_test_runner_kwargs()`](/ja/6.1/topics/testing/advanced/#django.test.runner.DiscoverRunner.get_test_runner_kwargs) to allow customizing the
  keyword arguments passed to the test runner.
- Added the [`test --debug-mode`](/ja/6.1/ref/django-admin/#cmdoption-test-debug-mode) option to help troubleshoot test
  failures by setting the [`DEBUG`](/ja/6.1/ref/settings/#std-setting-DEBUG) setting to `True`.
- The new [`django.test.utils.setup_databases()`](/ja/6.1/topics/testing/advanced/#django.test.utils.setup_databases) (moved from
  `django.test.runner`) and [`teardown_databases()`](/ja/6.1/topics/testing/advanced/#django.test.utils.teardown_databases)
  functions make it easier to build custom test runners.
- Added support for [`unittest.TestCase.subTest()`](https://docs.python.org/3/library/unittest.html#unittest.TestCase.subTest)’s when using the
  [`test --parallel`](/ja/6.1/ref/django-admin/#cmdoption-test-parallel) option.
- `DiscoverRunner` now runs the system checks at the start of a test run.
  Override the [`DiscoverRunner.run_checks()`](/ja/6.1/topics/testing/advanced/#django.test.runner.DiscoverRunner.run_checks) method if you want to disable
  that.

#### バリデータ

- ファイル拡張子を検証する [`FileExtensionValidator`](/ja/6.1/ref/validators/#django.core.validators.FileExtensionValidator) と、 画像ファイルを検証する [`validate_image_file_extension`](/ja/6.1/ref/validators/#django.core.validators.validate_image_file_extension) を追加しました。

## 1.11 における後方互換性のない変更

### [`django.contrib.gis`](/ja/6.1/ref/contrib/gis/#module-django.contrib.gis)

- To simplify the codebase and because it's easier to install than when
  `contrib.gis` was first released, [GDAL](/ja/6.1/ref/contrib/gis/install/geolibs/#gdalbuild) is now a required
  dependency for GeoDjango. In older versions, it's only required for SQLite.
- `contrib.gis.maps` is removed as it interfaces with a retired version of
  the Google Maps API and seems to be unmaintained. If you're using it,
  [let us know](https://code.djangoproject.com/ticket/14284).
- The `GEOSGeometry` equality operator now also compares SRID.
- The OpenLayers-based form widgets now use OpenLayers 3, and the
  `gis/openlayers.html` and `gis/openlayers-osm.html` templates have been
  updated. Check your project if you subclass these widgets or extend the
  templates. Also, the new widgets work a bit differently than the old ones.
  Instead of using a toolbar in the widget, you click to draw, click and drag
  to move the map, and click and drag a point/vertex/corner to move it.
- Support for SpatiaLite \< 4.0 is dropped.
- Support for GDAL 1.7 and 1.8 is dropped.
- The widgets in `contrib.gis.forms.widgets` and the admin's
  `OpenLayersWidget` use the [form rendering API](/ja/6.1/ref/forms/renderers/)
  rather than `loader.render_to_string()`. If you're using a custom widget
  template, you'll need to be sure your form renderer can locate it. For
  example, you could use the [`TemplatesSetting`](/ja/6.1/ref/forms/renderers/#django.forms.renderers.TemplatesSetting)
  renderer.

### [`django.contrib.staticfiles`](/ja/6.1/ref/contrib/staticfiles/#module-django.contrib.staticfiles)

- `collectstatic` may now fail during post-processing when using a hashed
  static files storage if a reference loop exists (e.g. `'foo.css'`
  references `'bar.css'` which itself references `'foo.css'`) or if the
  chain of files referencing other files is too deep to resolve in several
  passes. In the latter case, increase the number of passes using
  [`ManifestStaticFilesStorage.max_post_process_passes`](/ja/6.1/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.max_post_process_passes).
- When using `ManifestStaticFilesStorage`, static files not found in the
  manifest at runtime now raise a `ValueError` instead of returning an
  unchanged path. You can revert to the old behavior by setting
  [`ManifestStaticFilesStorage.manifest_strict`](/ja/6.1/ref/contrib/staticfiles/#django.contrib.staticfiles.storage.ManifestStaticFilesStorage.manifest_strict) to `False`.

### データベースバックエンド API

このセクションでは、サードパーティのデータベースバックエンドで必要になる可能性のある変更について説明します。

- The `DatabaseOperations.time_trunc_sql()` method is added to support
  `TimeField` truncation. It accepts a `lookup_type` and `field_name`
  arguments and returns the appropriate SQL to truncate the given time field
  `field_name` to a time object with only the given specificity. The
  `lookup_type` argument can be either `'hour'`, `'minute'`, or
  `'second'`.
- The `DatabaseOperations.datetime_cast_time_sql()` method is added to
  support the [`time`](/ja/6.1/ref/models/querysets/#std-fieldlookup-time) lookup. It accepts a `field_name` and `tzname`
  arguments and returns the SQL necessary to cast a datetime value to time
  value.
- To enable `FOR UPDATE SKIP LOCKED` support, set
  `DatabaseFeatures.has_select_for_update_skip_locked = True`.
- The new `DatabaseFeatures.supports_index_column_ordering` attribute
  specifies if a database allows defining ordering for columns in indexes. The
  default value is `True` and the `DatabaseIntrospection.get_constraints()`
  method should include an `'orders'` key in each of the returned
  dictionaries with a list of `'ASC'` and/or `'DESC'` values corresponding
  to the ordering of each column in the index.
- [`inspectdb`](/ja/6.1/ref/django-admin/#django-admin-inspectdb) no longer calls `DatabaseIntrospection.get_indexes()`
  which is deprecated. Custom database backends should ensure all types of
  indexes are returned by `DatabaseIntrospection.get_constraints()`.
- Renamed the `ignores_quoted_identifier_case` feature to
  `ignores_table_name_case` to more accurately reflect how it is used.
- The `name` keyword argument is added to the
  `DatabaseWrapper.create_cursor(self, name=None)` method to allow usage of
  server-side cursors on backends that support it.

### Dropped support for PostgreSQL 9.2 and PostGIS 2.0

Upstream support for PostgreSQL 9.2 ends in September 2017. As a consequence,
Django 1.11 sets PostgreSQL 9.3 as the minimum version it officially supports.

Support for PostGIS 2.0 is also removed as PostgreSQL 9.2 is the last version
to support it.

Also, the minimum supported version of psycopg2 is increased from 2.4.5 to
2.5.4.

### `LiveServerTestCase` binds to port zero

Rather than taking a port range and iterating to find a free port,
`LiveServerTestCase` binds to port zero and relies on the operating system
to assign a free port. The `DJANGO_LIVE_TEST_SERVER_ADDRESS` environment
variable is no longer used, and as it's also no longer used, the
`manage.py test --liveserver` option is removed.

If you need to bind `LiveServerTestCase` to a specific port, use the `port`
attribute added in Django 1.11.2.

### [`django.contrib.auth`](/ja/6.1/topics/auth/#module-django.contrib.auth) や `i18n` ビューでの安全でないリダイレクトに対する保護

`LoginView`、`LogoutView` (廃止される関数ベースのビュー) および [`set_language()`](/ja/6.1/topics/i18n/translation/#django.views.i18n.set_language) は、アプリケーションが HTTPS で動作しているとき、非 HTTPS の `next` URL へのリダイレクトからユーザを保護します。

### `QuerySet.get_or_create()` と `update_or_create()` の引数の検証

警告なしに引数を渡すことでタイポが発生するのを防ぐため、[`get_or_create()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.get_or_create) と [`update_or_create()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.update_or_create) が、引数がモデルフィールドかどうかをチェックするようになりました。これはプロジェクト内のバグを顕在化するので、後方互換性がないと言えます。

### `pytz` は必須の依存となり、`settings.TIME_ZONE = None` のサポートは削除されました。

Django のタイムゾーン処理をシンプルにするため、`pytz` が必須の依存となりました。Django とともに自動的にインストールされます。

`settings.TIME_ZONE = None` のサポートは削除されました、この動作は一般的に使用されておらず、有用性に疑問があるためです。システムのタイムゾーンに基づいて自動的にタイムゾーンを検出したい場合は、 [tzlocal](https://pypi.org/project/tzlocal/): が使用できます:

```
from tzlocal import get_localzone

TIME_ZONE = get_localzone().zone
```

This works similar to `settings.TIME_ZONE = None` except that it also sets
`os.environ['TZ']`. [Let us know](https://groups.google.com/g/django-developers/c/OAV3FChfuPM/discussion)
if there's a use case where you find you can't adapt your code to set a
`TIME_ZONE`.

### admin テンプレート内の HTML の変更

`<p class="help">` が `<div>` タグに置き換えられ、ヘルプテキスト内にリストを含められるようになりました。

読み取り専用のフィールドが `<p>...</p>` ではなく `<div class="readonly">...</div>` でラップされるようになり、どんな種類の HTML でもフィールドのコンテンツとして使えるようになりました。

### テンプレートベースのウィジェットレンダリングの導入による変更

`django.forms.widgets` 内の、ドキュメント化されていないいくつかのクラスが削除されました:

- `SubWidget`
- `RendererMixin`、`ChoiceFieldRenderer`、`RadioFieldRenderer`、`CheckboxFieldRenderer`
- `ChoiceInput`、`RadioChoiceInput`、`CheckboxChoiceInput`

The undocumented `Select.render_option()` method is removed.

`Widget.format_output()` メソッドは削除されました。代わりにカスタムウィジェットテンプレートを使用してください。

いくつかのウィジェット値 (たとえば `<select>` オプション) が、`settings.USE_L10N=True` の場合にローカル化されるようになりました。ローカル化を無効にする [`localize`](/ja/6.1/topics/i18n/formatting/#std-templatetag-localize) テンプレートタグを使ったカスタムウィジェットテンプレートを使用すれば、旧来の動作に戻すことができます。

### `django.template.backends.django.Template.render()` prohibits non-dict context

For compatibility with multiple template engines,
`django.template.backends.django.Template.render()` (returned from high-level
template loader APIs such as `loader.get_template()`) must receive a
dictionary of context rather than `Context` or `RequestContext`. If you
were passing either of the two classes, pass a dictionary instead -- doing so
is backwards-compatible with older versions of Django.

### マイグレーション処理でのモデル状態の変更

マイグレーション適用のスピードを改善するため、処理が必要とするまで関連モデルのレンダリングを送らせるようになりました (例: `RunPython`)。`database_forwards()` や `database_backwards()` の `from_state` 引数からモデルクラスやモデルインスタンスを操作するような独自の処理を作成していた場合、[独自のマイグレーション処理を記述する](/ja/6.1/ref/migration-operations/#writing-your-own-migration-operation) で説明しているように、`clear_delayed_apps_cache()` メソッドを使ってモデル状態をレンダリングする必要があります。

### Server-side cursors on PostgreSQL

The change to make [`QuerySet.iterator()`](/ja/6.1/ref/models/querysets/#django.db.models.query.QuerySet.iterator) use server-side cursors on
PostgreSQL prevents running Django with PgBouncer in transaction pooling mode.
To reallow that, use the [`DISABLE_SERVER_SIDE_CURSORS`](/ja/6.1/ref/settings/#std-setting-DATABASE-DISABLE_SERVER_SIDE_CURSORS) setting (added in Django 1.11.1) in
[`DATABASES`](/ja/6.1/ref/settings/#std-setting-DATABASES).

See [トランザクションプールとサーバーサイドカーソル](/ja/6.1/ref/databases/#transaction-pooling-server-side-cursors) for more discussion.

### その他

- フィードのアイテムが `pubdate` や `updateddate` 属性を持たない場合、[`SyndicationFeed.latest_post_date()`](/ja/6.1/ref/utils/#django.utils.feedgenerator.SyndicationFeed.latest_post_date) がタイムゾーン情報を持たない日時ではなく現在の UTC 日/時を返すようになりました。
- CSRF の失敗が `django.request` ではなく `django.security.csrf` ロガーに記録されるようになりました。
- [`ALLOWED_HOSTS`](/ja/6.1/ref/settings/#std-setting-ALLOWED_HOSTS) バリデーションが、テスト時に無効化されないようになりました。アプリケーションが独自のホスト名でのテストを含む場合、そのホスト名を [`ALLOWED_HOSTS`](/ja/6.1/ref/settings/#std-setting-ALLOWED_HOSTS) に含める必要があります。[テストとマルチホスト名](/ja/6.1/topics/testing/advanced/#topics-testing-advanced-multiple-hosts) を参照してください。
- `ModelAdmin.list_display` で外部キーの ID (e.g. `'field_id'`) を使用すると関連オブジェクトの ID を表示するようになりました。旧来の動作であるオブジェクトの文字列表現を使いたい場合は、`_id` サフィックスを削除してください。
- モデルフォーム内で、`null=True` の [`CharField`](/ja/6.1/ref/models/fields/#django.db.models.CharField) が、ブランク値に対して空の文字列ではなく `NULL` を保存するようになりました。
- Oracleでは、データベースが値を `NULL` として解釈するため、[`Model.validate_unique()`](/ja/6.1/ref/models/instances/#django.db.models.Model.validate_unique) が一意性に対する空の文字列をチェックしなくなりました。
- [`AbstractUser`](/ja/6.1/topics/auth/customizing/#django.contrib.auth.models.AbstractUser) をサブクラス化して `clean()` をオーバーライドする場合、`super()` を呼ぶようにしてください。モデルフォームバリデーションのような場合に標準化が適用されるよう、新たな [`AbstractUser.clean()`](/ja/6.1/topics/auth/customizing/#django.contrib.auth.models.AbstractUser.clean) メソッド内で [`BaseUserManager.normalize_email()`](/ja/6.1/topics/auth/customizing/#django.contrib.auth.models.BaseUserManager.normalize_email) が呼ばれます。
- `EmailField` と `URLField` が キーワード引数 `strip` を受け付けなくなりました。受け付けなくなった理由は、古いバージョンのDjangoでは、常に空白を取り除いており、効果がないからです。
- フォームウィジェットでレンダリングされる `checked` と `selected` 属性が、XHTML の `checked='checked'` や `selected='selected'` ではなく HTML5 ブール値シンタックスを使用するようになりました。
- [`RelatedManager.add()`](/ja/6.1/ref/models/relations/#django.db.models.fields.related.RelatedManager.add)、[`remove()`](/ja/6.1/ref/models/relations/#django.db.models.fields.related.RelatedManager.remove)、[`clear()`](/ja/6.1/ref/models/relations/#django.db.models.fields.related.RelatedManager.clear)、[`set()`](/ja/6.1/ref/models/relations/#django.db.models.fields.related.RelatedManager.set) が `prefetch_related()` キャッシュをクリアするようになりました。
- 保存した値を失わないように、[`teardown_test_environment()`](/ja/6.1/topics/testing/advanced/#django.test.utils.teardown_test_environment) を呼び出す前に 2 度めの呼び出しをした場合、[`setup_test_environment()`](/ja/6.1/topics/testing/advanced/#django.test.utils.setup_test_environment) がエラーを投げるようになりました。
- [`DjangoJSONEncoder`](/ja/6.1/topics/serialization/#django.core.serializers.json.DjangoJSONEncoder) (Django 1.0 でリネームされました) に対する、ドキュメント化していない `DateTimeAwareJSONEncoder` エイリアスが削除されました。
- The [`cached template loader`](/ja/6.1/ref/templates/api/#django.template.loaders.cached.Loader)
  is now enabled if [`OPTIONS['loaders']`](/ja/6.1/ref/settings/#std-setting-TEMPLATES-OPTIONS) isn't
  specified and [`OPTIONS['debug']`](/ja/6.1/ref/settings/#std-setting-TEMPLATES-OPTIONS) is `False`
  (the latter option defaults to the value of [`DEBUG`](/ja/6.1/ref/settings/#std-setting-DEBUG)). This could
  be backwards-incompatible if you have some [template tags that aren't
  thread safe](/ja/6.1/howto/custom-template-tags/#template-tag-thread-safety).
- 古いコンテンツタイプ削除のプロンプトが、 `migrate` コマンド後に表示されなくなりました。代わりに、新たな [`remove_stale_contenttypes`](/ja/6.1/ref/django-admin/#django-admin-remove_stale_contenttypes) コマンドを使用してください。
- `IntegerField` に対する admin のウィジェットが `type="text"` ではなく `type="number"` を使うようになりました。
- 条件付き HTTP ヘッダが、古い [**RFC 2616**](https://datatracker.ietf.org/doc/html/rfc2616.html) ではなく [**RFC 7232**](https://datatracker.ietf.org/doc/html/rfc7232.html) 条件付きリクエストの仕様によって解析および比較されるようになりました。
- [`patch_response_headers()`](/ja/6.1/ref/utils/#django.utils.cache.patch_response_headers) が `Last-Modified` ヘッダを追加しないようになりました。[**RFC 7234 Section 4.2.2**](https://datatracker.ietf.org/doc/html/rfc7234.html#section-4.2.2) によると、明示的な有効期限を提供する他のキャッシングヘッダ (たとえば `Expires` や `Cache-Control`) とともに無用となりました。[`UpdateCacheMiddleware`](/ja/6.1/ref/middleware/#django.middleware.cache.UpdateCacheMiddleware) および [`add_never_cache_headers()`](/ja/6.1/ref/utils/#django.utils.cache.add_never_cache_headers) は `patch_response_headers()` を呼び出すため、この変更の影響を受けます。
- admin テンプレート内で、`<p class="help">` が `<div>` タグに置き換えられ、ヘルプテキスト内にリストを含められるようになりました。
- [`ConditionalGetMiddleware`](/ja/6.1/ref/middleware/#django.middleware.http.ConditionalGetMiddleware) no longer sets the
  `Date` header as web servers set that header. It also no longer sets the
  `Content-Length` header as this is now done by
  [`CommonMiddleware`](/ja/6.1/ref/middleware/#django.middleware.common.CommonMiddleware).

  If you have a middleware that modifies a response's content and appears
  before `CommonMiddleware` in the `MIDDLEWARE` or `MIDDLEWARE_CLASSES`
  settings, you must reorder your middleware so that responses aren't modified
  after `Content-Length` is set, or have the response modifying middleware
  reset the `Content-Length` header.
- すべてのアプリケーションのモデルが読み込まれる前に呼び出された場合、[`get_model()`](/ja/6.1/ref/applications/#django.apps.AppConfig.get_model) および [`get_models()`](/ja/6.1/ref/applications/#django.apps.AppConfig.get_models) が [`AppRegistryNotReady`](/ja/6.1/ref/exceptions/#django.core.exceptions.AppRegistryNotReady) を投げるようになりました。以前は対象のアプリケーションのモデルが読み込まれることのみが必須で、リレーションシップのセットアップなしでモデルを返すことができました。`get_model()` の旧来の動作が必要な場合は、`require_ready` 引数を `False` にセットしてください。
- 無用な `BaseCommand.can_import_settings` 属性が削除されました。
- ドキュメント化されていなかった `django.utils.functional.lazy_property` が削除されました。
- 非マルチパートのリクエストとの整合性のため、`MultiPartParser.parse()` が `request.POST` を不変のままにするようになりました。したがってこの `QueryDict` を修正する場合は、まずコピーする必要があります (例: `request.POST.copy()`)。
- `cx_Oracle` 5.2 未満へのサポートが削除されました。
- IPython 1.0 未満へのサポートが `shell` コマンドから削除されました。
- The signature of private API `Widget.build_attrs()` changed from
  `extra_attrs=None, **kwargs` to `base_attrs, extra_attrs=None`.
- File-like objects (e.g., [`StringIO`](https://docs.python.org/3/library/io.html#io.StringIO) and [`BytesIO`](https://docs.python.org/3/library/io.html#io.BytesIO))
  uploaded to an [`ImageField`](/ja/6.1/ref/models/fields/#django.db.models.ImageField) using the test client
  now require a `name` attribute with a value that passes the
  [`validate_image_file_extension`](/ja/6.1/ref/validators/#django.core.validators.validate_image_file_extension) validator.
  See the note in [`Client.post()`](/ja/6.1/topics/testing/tools/#django.test.Client.post).
- [`FileField`](/ja/6.1/ref/models/fields/#django.db.models.FileField) now moves rather than copies the file
  it receives. With the default file upload settings, files larger than
  [`FILE_UPLOAD_MAX_MEMORY_SIZE`](/ja/6.1/ref/settings/#std-setting-FILE_UPLOAD_MAX_MEMORY_SIZE) now have the same permissions as
  temporary files (often `0o600`) rather than the system's standard umask
  (often `0o6644`). Set the [`FILE_UPLOAD_PERMISSIONS`](/ja/6.1/ref/settings/#std-setting-FILE_UPLOAD_PERMISSIONS) if you need
  the same permission regardless of file size.

## 1.11 で非推奨となった機能

### `models.permalink()` デコレータ

代わりに [`django.urls.reverse()`](/ja/6.1/ref/urlresolvers/#django.urls.reverse) を使用してください。例えば:

```
from django.db import models

class MyModel(models.Model):
    ...

    @models.permalink
    def url(self):
        return ("guitarist_detail", [self.slug])
```

は、以下のようになります:

```
from django.db import models
from django.urls import reverse

class MyModel(models.Model):
    ...

    def url(self):
        return reverse("guitarist_detail", args=[self.slug])
```

### その他

- 新たなクラスベースビュー [`LoginView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.LoginView) と [`LogoutView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.LogoutView) が採用されたため、`contrib.auth` の `login()` および `logout()` 関数ベースビューは非推奨となりました。
- `contrib.auth.views.logout_then_login()` の無用の `extra_context` パラメータが非推奨となりました。
- 新たなクラスベースビュー [`PasswordChangeView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordChangeView)、[`PasswordChangeDoneView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordChangeDoneView)、[`PasswordResetView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetView)、[`PasswordResetDoneView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetDoneView)、[`PasswordResetConfirmView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetConfirmView)、[`PasswordResetCompleteView`](/ja/6.1/topics/auth/default/#django.contrib.auth.views.PasswordResetCompleteView) が採用されたため、`contrib.auth` の `password_change()`、`password_change_done()`、`password_reset()`、`password_reset_done()`、`password_reset_confirm()`、`password_reset_complete()` は非推奨となりました。
- `django.test.runner.setup_databases()` が [`django.test.utils.setup_databases()`](/ja/6.1/topics/testing/advanced/#django.test.utils.setup_databases) に移動しました。旧来の場所は非推奨となります。
- [`django.utils.text.format_lazy()`](/ja/6.1/ref/utils/#django.utils.text.format_lazy) が採用されたため、`django.utils.translation.string_concat()` は非推奨となりました。`string_concat(*strings)` は `format_lazy('{}' * len(strings), *strings)` で置き換えることができます。
- `PyLibMCCache` キャッシュバックエンドに対して、`pylibmc` 動作設定を `OPTIONS` のトップレベル属性として渡すことは非推奨となりました。代わりに、`OPTIONS` 内の `behaviors`  キー下にセットしてください。
- 新たな `allowed_hosts` が採用されたため、`django.utils.http.is_safe_url()` の `host` は非推奨となりました。
- 有用性よりも混乱の原因になることが多いため、[`{% include %}`](/ja/6.1/ref/templates/builtins/#std-templatetag-include) テンプレートタグをレンダリングするときに投げられる例外を無効化することは非推奨となりました。Django 2.1 で、この例外は投げられるようになります。
- `DatabaseIntrospection.get_constraints()` が採用されたため、`DatabaseIntrospection.get_indexes()` は非推奨となりました。
- [`authenticate()`](/ja/6.1/topics/auth/default/#django.contrib.auth.authenticate) が認証バックエンドの `authenticate()` メソッドに `request` 引数を渡すようになりました。`request` を第 1 省略可能引数として受け取らないメソッドへのサポートは Django 2.1 で削除されます。
- 設定にかかわらず `ETag` ヘッダをレスポンスに追加するようになった [`ConditionalGetMiddleware`](/ja/6.1/ref/middleware/#django.middleware.http.ConditionalGetMiddleware) が採用されたため、`USE_ETAGS` 設定は非推奨となりました。 `CommonMiddleware` および `django.utils.cache.patch_response_headers()` は非推奨が終了するときに ETags をセットしなくなります。
- `Model._meta.auto_field が None かどうか` をチェックする方法が採用されたので、`Model._meta.has_auto_field` は非推奨となりました。
- `url()` 内で `iLmsu#` で正規表現グループを使用することは非推奨となりました。大文字と小文字を区別しない URL に対して有用なグループは `(?i)` のみとなりますが、大文字と小文字を区別しない URL は、たとえば検索エンジン用に複数のエントリを作成するため、適切ではありません。 代わりの解決方法として、URL 内で大文字を検索して小文字の同等の URL にリダイレクトするような [`handler404`](/ja/6.1/ref/urls/#django.conf.urls.handler404) を作成する方法があります。
- [`Widget.render()`](/ja/6.1/ref/forms/widgets/#django.forms.Widget.render) メソッドに `renderer` 引数が追加されました。廃止されるまでは、この引数を受け取らないメソッドも動作します。
