April 4, 2017
Django 1.11 へようこそ!
このリリースノートでは、Django 1.10 および過去のバージョンからアップグレードする際に知っておくべきいくつかの 後方互換性のない変更 に加え、新機能 を説明しています。いくつかの機能に対する廃止プロセスを開始しました。
既存のプロジェクトをアップデートするときは、 Django の新しいバージョンへの更新 ガイドに従ってください。
Django 1.11 is designated as a long-term support release. It will receive security updates for at least three years after its release. Support for the previous LTS, Django 1.8, will end in April 2018.
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.db.models.indexes モジュールはデータベースインデックスの作成を簡単にするクラスを含んでいます。インデックスは Meta.indexes オプションを使ってモデルに追加されます。
The Index class creates a b-tree index, as if you
used 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. It also allows defining the
order (ASC/DESC) for the columns of the index.
ウィジェットのカスタマイズを簡単にするため、フォームウィジェットの表示が Python 内ではなくテンプレートシステムを使って行われるようになりました。フォームレンダリング API を参照してください。
いくつかの 後方互換性のない変更 のため、実装済みのカスタムウィジェットを調整する必要があるかもしれません。
Subquery 表現¶新たな Subquery と Exists データベース表現によって、明示的なサブクエリを作成することができます。サブクエリは、OuterRef を使って外部のクエリセットからフィールドを参照することができます。
django.contrib.admin¶ModelAdmin.date_hierarchy はリレーションシップを通じてフィールドを参照できるようになりました。
新たな ModelAdmin.get_exclude() フックによって、リクエストやモデルインスタンスに基づいた除外フィールドを指定できます。
popup_response.html テンプレートが、アプリケーションごと、モデルごと、もしくはセッティング ModelAdmin.popup_response_template 属性によってオーバーライドできるようになりました。
django.contrib.auth¶PBKDF2 パスワードハッシュに対するデフォルトのイテレーションカウントが 20% 増加しました。
LoginView と LogoutView クラスベースビューが、廃止される login() と logout() 関数ベースビューの後継となりました。
PasswordChangeView、PasswordChangeDoneView、PasswordResetView、PasswordResetDoneView、PasswordResetConfirmView、PasswordResetCompleteView クラスベースビューが、廃止される password_change()、password_change_done()、password_reset()、password_reset_done()、password_reset_confirm()、password_reset_complete() 関数ビューの後継となりました。
PasswordResetConfirmView の新しい post_reset_login 属性によって、パスワードリセットが成功した後に自動的にログインできるようになりました。複数の AUTHENTICATION_BACKENDS を設定している場合、post_reset_login_backend 属性を使ってどれを使うか選択してください。
HTTP リファラヘッダを通じてパスワードリセットトークンが漏れる可能性を防ぐため (たとえば、リセットページが他のドメインにホストされた CSS や JavaScript への参照を含む場合)、PasswordResetConfirmView (廃止される password_reset_confirm() 関数ベースビューではありません) セッションにトークンを保持し、自身にリダイレクトして URL 内のトークンなしでユーザへのパスワード変更フォームを送信します。
update_session_auth_hash() がセッションキーをローテーションさせるようになり、パスワード変更が盗聴されたセッションクッキーを無効化できるようになりました。
LoginView と LogoutView の新しい success_url_allowed_hosts 属性によって、ログインおよびログアウト後のリダイレクトに対して安全なホストのセットを指定できるようになりました。
パスワードのバリデータ help_text が UserCreationForm に追加されました。
HttpRequest が authenticate() に渡されるようになりました。これは、request 属性を受け入れる場合にリクエストを認証バックエンドに順番に渡します。
user_login_failed() シグナルが request 属性を受け取るようになりました。
PasswordResetForm は 'email' ではない名前の E メールフィールドを使うカスタムユーザーモデルをサポートします。CustomUser.EMAIL_FIELD をフィールドの名前にセットしてください。
モデルを定義するモジュール内においても、get_user_model() をインポート時に呼ぶことができるようになりました。
django.contrib.contenttypes¶When stale content types are detected in the
remove_stale_contenttypes command, there's now a list of related
objects such as auth.Permissions 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¶新たな GEOSGeometry.from_gml() と OGRGeometry.from_gml() メソッドによって、GML から幾何学的配置を作成できるようになりました。
Added support for the dwithin lookup on SpatiaLite.
The Area function,
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 objects.
Added SpatiaLite support for the
IsValid function,
MakeValid function, and
isvalid lookup.
Added Oracle support for the
AsGML function,
BoundingCircle function,
IsValid function, and
isvalid lookup.
django.contrib.postgres¶The new distinct argument for
StringAgg determines if
concatenated values will be distinct.
The new GinIndex and
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 によるマイグレーション操作により、 PostgreSQL の citext 拡張を大文字小文字の区別なく検索できるようになりました。 ここでは、 CICharField 、 CIEmailField 、 CITextField の3つのフィールドが追加されます。
The new JSONBAgg allows
aggregating values as a JSON array.
The HStoreField (model field) and
HStoreField (form field) allow
storing null values.
Memcached backends now pass the contents of OPTIONS
as keyword arguments to the client constructors, allowing for more advanced
control of client behavior. See the cache arguments
documentation for examples.
Memcached backends now allow defining multiple servers as a comma-delimited
string in LOCATION, for convenience with
third-party services that use such strings in environment variables.
Added the 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()
on PostgreSQL 9.5+ and Oracle to execute queries with
FOR UPDATE SKIP LOCKED.
Added the TEST['TEMPLATE'] setting to let
PostgreSQL users specify a template for creating the test database.
QuerySet.iterator() がPostgreSQLで サーバサイドカーソル を使用するようになりました。この機能により、(クエリ結果を保持するために使用される)ワーカのメモリ負荷の一部がデータベースに転送され、データベースのメモリ使用量が増加する可能性があります。
Added MySQL support for the 'isolation_level' option in
OPTIONS to allow specifying the transaction 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.
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 でラップできるように、File に readable()、 writable()、 seekable() メソッドが追加されました。
The new empty_value attribute on CharField,
EmailField, RegexField,
SlugField, and URLField allows
specifying the Python value to use to represent "empty".
新たな Form.get_initial_for_field() メソッドは、フォームフィールドに対する初期データを返します。
数値の書式および NUMBER_GROUPING 設定が単一ではない桁グルーピングをサポートするようになりました。
新たな loaddata --exclude オプションによって、フィクスチャからデータを読み込んでいる間にモデルとアプリケーションを除外することができるようになりました。
新たな diffsettings --default オプションによって、Django のデフォルトの設定以外の設定モジュールを指定し、対比できるようになりました。
app_label属性が showmigrations --plan アウトプットを制限するようになりました。
uuid.UUID オブジェクトのシリアライズに対するサポートを追加しました。
QuerySet.update_or_create() と get_or_create() の defaults 属性で呼び出し可能な値に対するサポートが追加されました。
ImageField now has a default
validate_image_file_extension validator.
(This validator moved to the form field in Django 1.11.2.)
Added support for time truncation to
Trunc functions.
Added the ExtractWeek function to
extract the week from DateField and
DateTimeField and exposed it through the
week lookup.
Added the TruncTime function to truncate
DateTimeField to its time component and exposed it
through the time lookup.
QuerySet.values() と values_list() の表現へのサポートを追加しました。
range のような複数属性を取るルックアップでのクエリ表現へのサポートを追加しました。
FileField で unique=True オプションを使用できるようになりました。
nulls_first と nulls_last パラメータを Expression.asc() と desc() に追加し、null 値の順序をコントロールできるようにしました。
新たな F 表現 bitleftshift() と bitrightshift() メソッドによって、ビットワイズシフトオペレーション ができるようになりました。
QuerySet.union()、intersection()、difference() を追加しました。
QueryDict.fromkeys() を追加しました。
CommonMiddleware が 非ストリーミングレスポンスに対して Content-Length レスポンスヘッダをセットするようになりました。
Added the SECURE_HSTS_PRELOAD setting to allow appending the
preload directive to the Strict-Transport-Security header.
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
can now be customized by passing a cls keyword argument to the
serializers.serialize() function.
DjangoJSONEncoder now serializes
timedelta objects (used by
DurationField).
mark_safe() can now be used as a decorator.
The Jinja2 template backend now
supports context processors by setting the 'context_processors' option in
OPTIONS.
The regroup tag now returns namedtuples instead of dictionaries
so you can unpack the group object directly in a loop, e.g.
{% for grouper, list in regrouped %}.
Added a resetcycle template tag to allow resetting the sequence of
the cycle template tag.
You can now specify specific directories for a particular
filesystem.Loader.
Added DiscoverRunner.get_test_runner_kwargs() to allow customizing the
keyword arguments passed to the test runner.
Added the test --debug-mode option to help troubleshoot test
failures by setting the DEBUG setting to True.
The new django.test.utils.setup_databases() (moved from
django.test.runner) and teardown_databases()
functions make it easier to build custom test runners.
Added support for unittest.TestCase.subTest()’s when using the
test --parallel option.
DiscoverRunner now runs the system checks at the start of a test run.
Override the DiscoverRunner.run_checks() method if you want to disable
that.
ファイル拡張子を検証する FileExtensionValidator と、 画像ファイルを検証する validate_image_file_extension を追加しました。
django.contrib.gis¶To simplify the codebase and because it's easier to install than when
contrib.gis was first released, GDAL 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.
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
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
renderer.
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.
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 to False.
このセクションでは、サードパーティのデータベースバックエンドで必要になる可能性のある変更について説明します。
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 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 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.
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 や i18n ビューでの安全でないリダイレクトに対する保護¶LoginView、LogoutView (廃止される関数ベースのビュー) および set_language() は、アプリケーションが HTTPS で動作しているとき、非 HTTPS の next URL へのリダイレクトからユーザを保護します。
QuerySet.get_or_create() と update_or_create() の引数の検証¶警告なしに引数を渡すことでタイポが発生するのを防ぐため、get_or_create() と update_or_create() が、引数がモデルフィールドかどうかをチェックするようになりました。これはプロジェクト内のバグを顕在化するので、後方互換性がないと言えます。
pytz は必須の依存となり、settings.TIME_ZONE = None のサポートは削除されました。¶Django のタイムゾーン処理をシンプルにするため、pytz が必須の依存となりました。Django とともに自動的にインストールされます。
settings.TIME_ZONE = None のサポートは削除されました、この動作は一般的に使用されておらず、有用性に疑問があるためです。システムのタイムゾーンに基づいて自動的にタイムゾーンを検出したい場合は、 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
if there's a use case where you find you can't adapt your code to set a
TIME_ZONE.
<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 テンプレートタグを使ったカスタムウィジェットテンプレートを使用すれば、旧来の動作に戻すことができます。
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 引数からモデルクラスやモデルインスタンスを操作するような独自の処理を作成していた場合、独自のマイグレーション処理を記述する で説明しているように、clear_delayed_apps_cache() メソッドを使ってモデル状態をレンダリングする必要があります。
The change to make 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 setting (added in Django 1.11.1) in
DATABASES.
See トランザクションプールとサーバーサイドカーソル for more discussion.
フィードのアイテムが pubdate や updateddate 属性を持たない場合、SyndicationFeed.latest_post_date() がタイムゾーン情報を持たない日時ではなく現在の UTC 日/時を返すようになりました。
CSRF の失敗が django.request ではなく django.security.csrf ロガーに記録されるようになりました。
ALLOWED_HOSTS バリデーションが、テスト時に無効化されないようになりました。アプリケーションが独自のホスト名でのテストを含む場合、そのホスト名を ALLOWED_HOSTS に含める必要があります。テストとマルチホスト名 を参照してください。
ModelAdmin.list_display で外部キーの ID (e.g. 'field_id') を使用すると関連オブジェクトの ID を表示するようになりました。旧来の動作であるオブジェクトの文字列表現を使いたい場合は、_id サフィックスを削除してください。
モデルフォーム内で、null=True の CharField が、ブランク値に対して空の文字列ではなく NULL を保存するようになりました。
Oracleでは、データベースが値を NULL として解釈するため、Model.validate_unique() が一意性に対する空の文字列をチェックしなくなりました。
AbstractUser をサブクラス化して clean() をオーバーライドする場合、super() を呼ぶようにしてください。モデルフォームバリデーションのような場合に標準化が適用されるよう、新たな AbstractUser.clean() メソッド内で BaseUserManager.normalize_email() が呼ばれます。
EmailField と URLField が キーワード引数 strip を受け付けなくなりました。受け付けなくなった理由は、古いバージョンのDjangoでは、常に空白を取り除いており、効果がないからです。
フォームウィジェットでレンダリングされる checked と selected 属性が、XHTML の checked='checked' や selected='selected' ではなく HTML5 ブール値シンタックスを使用するようになりました。
RelatedManager.add()、remove()、clear()、set() が prefetch_related() キャッシュをクリアするようになりました。
保存した値を失わないように、teardown_test_environment() を呼び出す前に 2 度めの呼び出しをした場合、setup_test_environment() がエラーを投げるようになりました。
DjangoJSONEncoder (Django 1.0 でリネームされました) に対する、ドキュメント化していない DateTimeAwareJSONEncoder エイリアスが削除されました。
The cached template loader
is now enabled if OPTIONS['loaders'] isn't
specified and OPTIONS['debug'] is False
(the latter option defaults to the value of DEBUG). This could
be backwards-incompatible if you have some template tags that aren't
thread safe.
古いコンテンツタイプ削除のプロンプトが、 migrate コマンド後に表示されなくなりました。代わりに、新たな remove_stale_contenttypes コマンドを使用してください。
IntegerField に対する admin のウィジェットが type="text" ではなく type="number" を使うようになりました。
条件付き HTTP ヘッダが、古い RFC 2616 ではなく RFC 7232 条件付きリクエストの仕様によって解析および比較されるようになりました。
patch_response_headers() が Last-Modified ヘッダを追加しないようになりました。RFC 7234 Section 4.2.2 によると、明示的な有効期限を提供する他のキャッシングヘッダ (たとえば Expires や Cache-Control) とともに無用となりました。UpdateCacheMiddleware および add_never_cache_headers() は patch_response_headers() を呼び出すため、この変更の影響を受けます。
admin テンプレート内で、<p class="help"> が <div> タグに置き換えられ、ヘルプテキスト内にリストを含められるようになりました。
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.
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() および get_models() が 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 and BytesIO)
uploaded to an ImageField using the test client
now require a name attribute with a value that passes the
validate_image_file_extension validator.
See the note in Client.post().
FileField now moves rather than copies the file
it receives. With the default file upload settings, files larger than
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 if you need
the same permission regardless of file size.
models.permalink() デコレータ¶代わりに 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 と LogoutView が採用されたため、contrib.auth の login() および logout() 関数ベースビューは非推奨となりました。
contrib.auth.views.logout_then_login() の無用の extra_context パラメータが非推奨となりました。
新たなクラスベースビュー PasswordChangeView、PasswordChangeDoneView、PasswordResetView、PasswordResetDoneView、PasswordResetConfirmView、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() に移動しました。旧来の場所は非推奨となります。
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 %} テンプレートタグをレンダリングするときに投げられる例外を無効化することは非推奨となりました。Django 2.1 で、この例外は投げられるようになります。
DatabaseIntrospection.get_constraints() が採用されたため、DatabaseIntrospection.get_indexes() は非推奨となりました。
authenticate() が認証バックエンドの authenticate() メソッドに request 引数を渡すようになりました。request を第 1 省略可能引数として受け取らないメソッドへのサポートは Django 2.1 で削除されます。
設定にかかわらず ETag ヘッダをレスポンスに追加するようになった 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 を作成する方法があります。
Widget.render() メソッドに renderer 引数が追加されました。廃止されるまでは、この引数を受け取らないメソッドも動作します。
7月 02, 2025