Django废弃时间表¶
本文档概述了根据弃用政策 deprecation policy 弃用后,各个Django版本将以向后不兼容的方式删除或更改的情况。 通常,可以在之前的两个版本的发行说明中找到有关每个项目的更多详细信息。
7.0¶
See the Django 6.0 release notes for more details on these changes.
The
serializekeyword argument ofBaseDatabaseCreation.create_test_db()will be removed.The
django.contrib.postgres.aggregates.StringAggclass will be removed.The
django.contrib.postgres.aggregates.mixins.OrderableAggMixinclass will be removed.The default protocol in
urlizeandurlizetrunctemplate filters will change from HTTP to HTTPS.The
URLIZE_ASSUME_HTTPStransitional setting will be removed.Using a percent sign in a column alias or annotation will raise
ValueError.Support for setting the
ADMINSorMANAGERSsettings to a list of (name, address) tuples will be removed.The
orphansargument being larger than or equal to theper_pageargument ofdjango.core.paginator.Paginatoranddjango.core.paginator.AsyncPaginatorwill no longer be allowed.The
django.core.mailAPIs will no longer accept certain parameters as positional arguments. These must be passed as keyword arguments instead.Support for passing Python's legacy email
email.mime.base.MIMEBaseobject toEmailMessage.attach()(or including one in the message'sattachmentslist) will be removed.The
django.core.mail.BadHeaderErrorexception will be removed.The
django.core.mail.SafeMIMETextandSafeMIMEMultipartclasses will be removed.The
django.core.mail.forbid_multi_line_headers()anddjango.core.mail.message.sanitize_address()functions will be removed.
See the Django 6.1 release notes for more details on these changes.
Calling
QuerySet.values_list()withflat=Trueand no field name will raiseTypeError.The use of
Nonewhen querying aJSONFieldtop-level value will compile to SQLIS NULL. UseJSONNullto query for a JSONnullvalue instead.The
django.db.models.fields.BLANK_CHOICE_DASHconstant will be removed.The
USE_BLANK_CHOICE_DASHtransitional setting will be removed.The
SIGNED_COOKIE_LEGACY_SALT_FALLBACKtransitional setting will be removed.The
Field.get_placeholder_sqlshim over the deprecatedget_placeholdermethod will be removed.The
SQLCompiler.quote_name_unless_alias()method will be removed.The
EMAIL_BACKEND,EMAIL_FILE_PATH,EMAIL_HOST,EMAIL_HOST_PASSWORD,EMAIL_HOST_USER,EMAIL_PORT,EMAIL_USE_TLS,EMAIL_USE_SSL,EMAIL_SSL_CERTFILE,EMAIL_SSL_KEYFILE, andEMAIL_TIMEOUTsettings will be removed.The
django.core.mail.get_connection()function will be removed.The
connection,fail_silently,auth_user, andauth_passwordarguments will be removed fromsend_mail(),send_mass_mail(),mail_admins(),mail_managers(), theEmailMessageconstructor, andEmailMessage.send(). Support for theEmailMessage.connectionattribute will also be removed.Directly creating instances of the
smtp.EmailBackendclass will become unsupported, and the class documentation for that backend will be removed.The
BaseEmailBackend.__init__()method will raise errors for unknown keyword arguments and will remove support forfail_silently.The
email_backendargument oflog.AdminEmailHandlerwill be removed.The
django.contrib.postgres.aggregates.BitAnd,django.contrib.postgres.aggregates.BitOr, anddjango.contrib.postgres.aggregates.BitXorclasses will be removed.Support for double-dot variable lookup, like
{{ book..title }}, is removed.The default value of the
algorithmargument fordjango.utils.crypto.salted_hmac()anddjango.core.signing.base64_hmac()will change from"sha1"to"sha256".Calling
QuerySet.select_related()without arguments will raiseTypeError.QuerySet.select_related()will raiseTypeErrorif passedTruerather thanAttributeError.ModelAdminwill raiseValueErrorif subclassed with itslist_select_relatedattribute set toTrue.ModelAdminwill raiseValueErrorif itsget_list_select_related()method returnsTrue.Support for overriding
ModelAdmin.get_actions()without the newaction_locationparameter will be removed.Support for unpacking or indexing the dictionary values of the
ModelAdmin.get_actions()return value will be removed. UseActionattributes instead.Support for overriding
ModelAdmin.get_action_choices()without the newaction_locationparameter will be removed.The
django.db.transaction.savepoint()alias todjango.db.transaction.savepoint_create()will be removed.
6.1¶
See the Django 5.2 release notes for more details on these changes.
The
allkeyword argument ofdjango.contrib.staticfiles.finders.find()will be removed.Fallbacks to
request.userandrequest.auser()whenuserisNoneindjango.contrib.auth.login()anddjango.contrib.auth.alogin(), respectively, will be removed.The
orderingkeyword argument of the PostgreSQL specific aggregation functionsdjango.contrib.postgres.aggregates.ArrayAgg,django.contrib.postgres.aggregates.JSONBAgg, anddjango.contrib.postgres.aggregates.StringAggwill be removed.Support for subclasses of
RemoteUserMiddlewarethat overrideprocess_request()without overridingaprocess_request()will be removed.
6.0¶
查看 Django 5.0 发布说明 以获取更多关于这些更改的详细信息。
DjangoDivFormRenderer和Jinja2DivFormRenderer过渡性表单渲染器将被移除。将移除对于将位置参数传递给
BaseConstraint的支持。request将在ModelAdmin.lookup_allowed()的子类的签名中变成必需。django.db.models.sql.datastructures.Join不再回退到get_joining_columns()。ForeignObject和ForeignObjectRel的get_joining_columns()方法将被移除。ForeignObject.get_reverse_joining_columns()方法将被移除。forms.URLField的默认方案将从"http"更改为"https"。不再支持在不传递 args 或 kwargs 的情况下调用
format_html()。不再支持
cx_Oracle。BaseDatabaseOperations.field_cast_sql()将被移除。ChoicesMeta到django.db.models.enums.ChoicesType的别名将被移除。Prefetch.get_current_queryset()方法将被移除。相关管理器和描述符的
get_prefetch_queryset()方法将被移除。get_prefetcher()和prefetch_related_objects()将不再回退到get_prefetch_queryset()。FORMS_URLFIELD_ASSUME_HTTPS过渡性设置将被移除。
有关这些更改的更多详细信息,请参阅 Django 5.1 发布说明。
ModelAdmin.log_deletion()和LogEntryManager.log_action()方法将被移除。未记录的
django.utils.itercompat.is_iterable()函数和django.utils.itercompat模块将被移除。django.contrib.gis.geoip2.GeoIP2.coords()方法将被移除。django.contrib.gis.geoip2.GeoIP2.open()方法将被移除。支持向
Model.save()和Model.asave()传递位置参数的功能将被移除。django.contrib.gis.gdal.OGRGeometry.coord_dim的设置器将被移除。django.urls.register_converter()将不再允许覆盖现有的转换器。CheckConstraint的check关键字参数将被移除。FileSystemStorage的OS_OPEN_FLAGS属性将被移除。FieldCacheMixin的get_cache_name()方法将被移除。
5.1¶
有关这些更改的更多详细信息,请参阅 Django 4.2 发布说明。
BaseUserManager.make_random_password()方法将被移除。模型的
Meta.index_together选项将被移除。length_is模板过滤器将被移除。将移除
django.contrib.auth.hashers.SHA1PasswordHasher、django.contrib.auth.hashers.UnsaltedSHA1PasswordHasher和django.contrib.auth.hashers.UnsaltedMD5PasswordHasher。模型
django.contrib.postgres.fields.CICharField、django.contrib.postgres.fields.CIEmailField和django.contrib.postgres.fields.CITextField将被移除。为了与历史迁移兼容,将保留存根字段。django.contrib.postgres.fields.CITextmixin 将被移除。BaseGeometryWidget的map_width和map_height属性将被移除。SimpleTestCase.assertFormsetError()方法将被移除。TransactionTestCase.assertQuerysetEqual()方法将被移除。将移除将编码的 JSON 字符串字面量传递给
JSONField以及相关查找和表达式的支持。将移除向
Signer和TimestampSigner传递位置参数的支持。将移除
DEFAULT_FILE_STORAGE和STATICFILES_STORAGE设置。django.core.files.storage.get_storage_class()函数将被移除。
5.0¶
有关这些更改的更多详细信息,请参阅 Django 4.0 发布说明。
SERIALIZE测试设置将被移除。未记录的
django.utils.baseconv模块将被移除。未记录的
django.utils.datetime_safe模块将被移除。USE_TZ设置的默认值将从False更改为True。在请求上下文之外构建的站点地图的默认站点地图协议将从
'http'更改为'https'。DiscoverRunner.build_suite()和DiscoverRunner.run_tests()的extra_tests参数将被移除。django.contrib.postgres.aggregates.ArrayAgg、JSONBAgg和StringAgg聚合在没有行时将返回None,而不再返回[]、[]和''。USE_L10N设置将被移除。USE_DEPRECATED_PYTZ过渡设置将被移除。将移除对
pytz时区的支持。is_dst参数将从以下方法中移除:QuerySet.datetimes()django.utils.timezone.make_aware()django.db.models.functions.Trunc()django.db.models.functions.TruncSecond()django.db.models.functions.TruncMinute()django.db.models.functions.TruncHour()django.db.models.functions.TruncDay()django.db.models.functions.TruncWeek()django.db.models.functions.TruncMonth()django.db.models.functions.TruncQuarter()django.db.models.functions.TruncYear()
django.contrib.gis.admin.GeoModelAdmin和OSMGeoAdmin类将被移除。未记录的
BaseForm._html_output()方法将被移除。在渲染
ErrorDict和ErrorList时返回str而不是SafeString的能力将被移除。
有关这些更改的更多详细信息,请参阅 Django 4.1 发布说明。
SitemapIndexItem.__str__()方法将被移除。CSRF_COOKIE_MASKED过渡设置将被移除。django.utils.functional.cached_property()的name参数将被移除。django.contrib.postgres.constraints.ExclusionConstraint的opclasses参数将被移除。未记录的能力传递
errors=None到SimpleTestCase.assertFormError()和assertFormsetError()将被移除。django.contrib.sessions.serializers.PickleSerializer将被移除。不再允许在预取相关对象的查询集上使用未提供
chunk_size参数的QuerySet.iterator()的用法。不再允许将未保存的模型实例传递给相关过滤器。
在
RemoteUserBackend.configure_user()子类的签名中将需要created=True。将移除通过
GET请求在django.contrib.auth.views.LogoutView和django.contrib.auth.views.logout_then_login()中注销的支持。django.utils.timezone.utc到datetime.timezone.utc的别名将被移除。不再允许将响应对象和表单/表单集名称传递给
SimpleTestCase.assertFormError()和assertFormsetError()。django.contrib.gis.admin.OpenLayersWidget将被移除。django.contrib.auth.hashers.CryptPasswordHasher将被移除。将移除模板
"django/forms/default.html"和"django/forms/formsets/default.html"。将移除在
Expression.asc()和Expression.desc()方法以及OrderBy表达式中传递nulls_first=False或nulls_last=False的能力。
4.1¶
请查看 Django 3.2 发布说明 以获取有关这些更改的更多详细信息。
将移除在
TestCase.setUpTestData()中将不支持使用copy.deepcopy()创建深拷贝的对象分配给类属性的支持。BaseCommand.requires_system_checks将不再支持布尔值。django.core.validators.EmailValidator的whitelist参数和domain_whitelist属性将被移除。将移除
default_app_config模块变量。TransactionTestCase.assertQuerysetEqual()不再在与字符串值比较时自动调用repr()来处理查询集。django.core.cache.backends.memcached.MemcachedCache将被移除。将移除对
django.contrib.messages.storage.cookie.CookieStorage使用的 Django 3.2 之前的消息格式的支持。
4.0¶
请查看 Django 3.0 发布说明 以获取有关这些更改的更多详细信息。
django.utils.http.urlquote(),urlquote_plus(),urlunquote(), 和urlunquote_plus()将被移除。django.utils.encoding.force_text()和smart_text()将被移除。django.utils.translation.ugettext(),ugettext_lazy(),ugettext_noop(),ungettext(), 和ungettext_lazy()将被移除。django.views.i18n.set_language()将不再在request.session中设置用户语言(键为django.utils.translation.LANGUAGE_SESSION_KEY)。在
django.db.models.Expression.get_group_by_cols()子类的签名中将需要alias=None。django.utils.text.unescape_entities()将被移除。django.utils.http.is_safe_url()将被移除。
请查看 Django 3.1 发布说明 以获取有关这些更改的更多详细信息。
PASSWORD_RESET_TIMEOUT_DAYS设置将被移除。不再允许在非布尔值作为右操作数的情况下使用未记录的
isnull查询。django.db.models.query_utils.InvalidQuery异常类将被移除。django-admin.py入口点将被移除。HttpRequest.is_ajax()方法将被移除。将移除
django.contrib.messages.storage.cookie.CookieStorage使用的 Django 3.1 之前的 Cookie 值的编码格式的支持。将移除在管理员网站中(使用 SHA-1 哈希算法的) Django 3.1 之前的密码重置令牌的支持。
将移除 Django 3.1 之前的会话编码格式的支持。
将移除在 Django 3.1 之前(使用 SHA-1 算法编码的)
django.core.signing.Signer签名的支持。将移除在 Django 3.1 之前使用 SHA-1 算法编码的
django.core.signing.dumps()签名在django.core.signing.loads()中的支持。将移除在 Django 3.1 之前(使用 SHA-1 算法的)用户会话的支持。
django.utils.deprecation.MiddlewareMixin.__init__()的get_response参数将需要,并且不会接受None。django.dispatch.Signal的providing_args参数将被移除。django.utils.crypto.get_random_string()的length参数将变为必填项。ModelMultipleChoiceField中的list消息将被移除。将移除将原始列别名传递给
QuerySet.order_by()的支持。模型
NullBooleanField将被移除,为了与历史迁移兼容,将保留一个存根字段。django.conf.urls.url()将被移除。模型
django.contrib.postgres.fields.JSONField将被移除,为了与历史迁移兼容,将保留一个存根字段。django.contrib.postgres.forms.JSONField、django.contrib.postgres.fields.jsonb.KeyTransform和django.contrib.postgres.fields.jsonb.KeyTextTransform将被移除。{% ifequal %}和{% ifnotequal %}模板标签将被移除。DEFAULT_HASHING_ALGORITHM过渡设置将被移除。
3.1¶
请查看 Django 2.2 发布说明 以获取有关这些更改的更多详细信息。
django.utils.timezone.FixedOffset将被移除。django.core.paginator.QuerySetPaginator将被移除。模型的
Meta.ordering将不再影响GROUP BY查询。django.contrib.postgres.fields.FloatRangeField和django.contrib.postgres.forms.FloatRangeField将被移除。FILE_CHARSET设置将被移除。django.contrib.staticfiles.storage.CachedStaticFilesStorage将被移除。RemoteUserBackend.configure_user()将要求将request作为第一个位置参数传递。将移除对
SimpleTestCase.allow_database_queries和TransactionTestCase.multi_db的支持。
3.0¶
请查看 Django 2.0 发布说明 以获取有关这些更改的更多详细信息。
django.db.backends.postgresql_psycopg2模块将被移除。django.shortcuts.render_to_response()将被移除。DEFAULT_CONTENT_TYPE设置将被移除。HttpRequest.xreadlines()将被移除。将移除对
Field.from_db_value()和Expression.convert_value()的context参数的支持。QuerySet.earliest()和latest()的field_name关键字参数将被移除。
请查看 Django 2.1 发布说明 以获取有关这些更改的更多详细信息。
django.contrib.gis.db.models.functions.ForceRHR将被移除。django.utils.http.cookie_date()将被移除。staticfiles和admin_static模板标签库将被移除。django.contrib.staticfiles.templatetags.static()将被移除。将移除允许定义
InlineModelAdmin.has_add_permission()时没有obj参数的兼容性层。
2.1¶
请查看 Django 1.11 发布说明 以获取有关这些更改的更多详细信息。
contrib.auth.views.login(),logout(),password_change(),password_change_done(),password_reset(),password_reset_done(),password_reset_confirm(), 和password_reset_complete()将被移除。contrib.auth.views.logout_then_login()的extra_context参数将被移除。django.test.runner.setup_databases()将被移除。django.utils.translation.string_concat()将被移除。django.core.cache.backends.memcached.PyLibMCCache将不再支持将pylibmc行为设置作为OPTIONS的顶级属性传递。django.utils.http.is_safe_url()的host参数将被移除。将移除在渲染
{% include %}模板标签时抑制异常的功能。DatabaseIntrospection.get_indexes()将被移除。认证后端的
authenticate()方法将要求将request作为第一个位置参数传递。django.db.models.permalink()装饰器将被移除。USE_ETAGS设置将被移除。CommonMiddleware和django.utils.cache.patch_response_headers()将不再设置 ETags。Model._meta.has_auto_field属性将被移除。url()对正则表达式组中的内联标志((?i),(?L),(?m),(?s), 和(?u))的支持将被移除。将移除没有
renderer参数的Widget.render()方法的支持。
2.0¶
请查看 Django 1.9 发布说明 以获取有关这些更改的更多详细信息。
django.dispatch.signals.Signal.disconnect()中的weak参数将被移除。django.db.backends.base.BaseDatabaseOperations.check_aggregate_support()将被移除。django.forms.extras包将被移除。assignment_tag助手将被移除。assertsRedirects中的host参数将被移除。还将移除兼容性层,允许在路径相同的情况下将绝对 URL 视为与相对 URL 相等。Field.rel将被移除。Field.remote_field.to属性将被移除。ForeignKey和OneToOneField的on_delete参数将变为必填项。django.db.models.fields.add_lazy_relation()将被移除。在启用时区支持时,不再将不支持时区的数据库后端将具有意识到时区的日期时间转换为 UTC 中的不明确值,当这些值作为参数传递给 ORM 之外执行的 SQL 查询,例如,使用
cursor.execute()时。django.contrib.auth.tests.utils.skipIfCustomUser()装饰器将被移除。GeoManager和GeoQuerySet类将被移除。django.contrib.gis.geoip模块将被移除。模板加载器中的
supports_recursion检查将从以下内容中移除:django.template.engine.Engine.find_template()django.template.loader_tags.ExtendsNode.find_template()django.template.loaders.base.Loader.supports_recursion()django.template.loaders.cached.Loader.supports_recursion()
load_template()和load_template_sources()模板加载器方法将被移除。模板加载器的
template_dirs参数将被移除:django.template.loaders.base.Loader.get_template()django.template.loaders.cached.Loader.cache_key()django.template.loaders.cached.Loader.get_template()django.template.loaders.cached.Loader.get_template_sources()django.template.loaders.filesystem.Loader.get_template_sources()
django.template.loaders.base.Loader.__call__()方法将被移除。将不再支持具有单个位置参数的自定义错误视图。
django.utils.feedgenerator.Atom1Feed和django.utils.feedgenerator.RssFeed的mime_type属性将被移除,而content_type将取而代之。django.conf.urls.include()的app_name参数将被移除。将移除将 3 元组作为
include()的第一个参数传递的支持。将移除在不设置应用程序命名空间的情况下设置 URL 实例命名空间的支持。
Field._get_val_from_obj()将被移除,取而代之的是Field.value_from_object()。django.template.loaders.eggs.Loader将被移除。contrib.auth视图的current_app参数将被移除。SimpleTestCase.assertRaisesMessage()函数的callable_obj关键字参数将被移除。在
ModelAdmin方法上的allow_tags属性的支持将被移除。SyndicationFeed.add_item()函数的enclosure关键字参数将被移除。django.template.loader.LoaderOrigin和django.template.base.StringOrigin对于django.template.base.Origin的别名将被移除。
请查看 Django 1.10 发布说明 以获取有关这些更改的更多详细信息。
makemigrations --exit选项将被移除。将移除直接对反向外键或多对多关系进行赋值的支持。
django.contrib.gis.geos.GEOSGeometry的get_srid()和set_srid()方法将被移除。django.contrib.gis.geos.Point的get_x()、set_x()、get_y()、set_y()、get_z()和set_z()方法将被移除。django.contrib.gis.geos.Point的get_coords()和set_coords()方法将被移除。django.contrib.gis.geos.MultiPolygon的cascaded_union属性将被移除。django.utils.functional.allow_lazy()将被移除。shell --plain选项将被移除。django.core.urlresolvers模块将被移除。模型
CommaSeparatedIntegerField将被移除。为了与历史迁移兼容性,将保留一个存根字段。模板中
Context.has_key()方法的支持将被移除。django.core.files.storage.Storage的accessed_time()、created_time()和modified_time()方法的支持将被移除。当设置了
Meta.default_related_name时,将移除使用模型名称进行查询查找的支持。__search查询查找以及DatabaseOperations.fulltext_search_sql()方法将被移除。将移除支持自定义相关管理器类但没有
_apply_rel_filters()方法的 shim。将不再支持使用
User.is_authenticated()和User.is_anonymous()作为方法。将移除
Model._meta的私有属性virtual_fields。Field.contribute_to_class()中的私有关键字参数virtual_only和Model._meta.add_field()中的virtual将被移除。javascript_catalog()和json_catalog()视图将被移除。django.contrib.gis.utils.precision_wkt()函数将被移除。在多表继承中,隐式将
OneToOneField提升为parent_link的操作将被移除。将移除对
Widget._format_value()的支持。FileField的方法get_directory_name()和get_filename()将被移除。将移除
mark_for_escaping()函数及其使用的类:EscapeData、EscapeBytes、EscapeText、EscapeString和EscapeUnicode。escape过滤器将更改为使用django.utils.html.conditional_escape()。将移除
Manager.use_for_related_fields。模型的
Manager继承将遵循 MRO 继承规则,并且用于选择此行为的Meta.manager_inheritance_from_future将被移除。将移除对使用
settings.MIDDLEWARE_CLASSES的旧式中间件的支持。
1.10¶
请查看 Django 1.8 发布说明 以获取有关这些更改的更多详细信息。
将移除直接调用
SQLCompiler作为调用其quote_name_unless_alias方法的别名的支持。cycle和firstof模板标签将从future模板标签库中移除(在 1.6/1.7 弃用期间使用)。django.conf.urls.patterns()将被移除。django.conf.urls.i18n.i18n_patterns()中的prefix参数支持将被移除。SimpleTestCase.urls将被移除。在模板标签
for中使用错误的解包值数量将引发异常,而不会默默失败。将移除使用点分隔的 Python 路径来反向生成 URL 的能力。
将移除对
LOGIN_URL和LOGIN_REDIRECT_URL设置使用点分隔的 Python 路径的能力。Support for
optparsewill be dropped for custom management commands (replaced byargparse).类
django.core.management.NoArgsCommand将被移除。请改用默认不接受参数的BaseCommand。django.core.context_processors模块将被移除。django.db.models.sql.aggregates模块将被移除。django.contrib.gis.db.models.sql.aggregates模块将被移除。以下是将被移除的
django.db.sql.query.Query的方法和属性:属性:
aggregates和aggregate_select将被移除。方法:
add_aggregate、set_aggregate_mask和append_aggregate_mask将被移除。
django.template.resolve_variable将被移除。以下是将从
django.db.models.options.Options(Model._meta) 中移除的私有 API:get_field_by_name()get_all_field_names()get_fields_with_model()get_concrete_fields_with_model()get_m2m_with_model()get_all_related_objects()get_all_related_objects_with_model()get_all_related_many_to_many_objects()get_all_related_m2m_objects_with_model()
django.forms.RegexField的error_message参数将被移除。unordered_list过滤器将不再支持旧式列表。将移除对字符串类型的
view参数在url()中的支持。将移除将
django.forms.Form._has_changed()重命名为has_changed()的向后兼容 shim。removetags模板过滤器将被移除。django.utils.html中的remove_tags()和strip_entities()函数将被移除。django.contrib.auth.views.password_reset()中的is_admin_site参数将被移除。django.db.models.field.subclassing.SubfieldBase将被移除。django.utils.checksums将被移除;其功能已包含在django-localflavor1.1+ 中。django.contrib.admin.helpers.InlineAdminForm上的original_content_type_id属性将被移除。将移除向后兼容的 shim,以允许
FormMixin.get_form()定义时不提供form_class参数的默认值。以下设置将被移除:
ALLOWED_INCLUDE_ROOTSTEMPLATE_CONTEXT_PROCESSORSTEMPLATE_DEBUGTEMPLATE_DIRSTEMPLATE_LOADERSTEMPLATE_STRING_IF_INVALID
向后兼容的别名
django.template.loader.BaseLoader将被移除。Django template objects returned by
get_template()andselect_template()won't accept aContextin theirrender()method anymore.Template response APIs 将强制使用
dict和依赖于后端的模板对象,而不再使用Context和Template。以下函数和类的
current_app参数将被移除:django.shortcuts.render()django.template.Context()django.template.RequestContext()django.template.response.TemplateResponse()
以下函数的
dictionary和context_instance参数将被移除:django.shortcuts.render()django.shortcuts.render_to_response()django.template.loader.render_to_string()
以下函数的
dirs参数将被移除:django.template.loader.get_template()django.template.loader.select_template()django.shortcuts.render()django.shortcuts.render_to_response()
会启用会话验证,不管
'django.contrib.auth.middleware.SessionAuthenticationMiddleware'是否在MIDDLEWARE_CLASSES中。私有属性
django.db.models.Field.related将被移除。migrate管理命令的--list选项将被移除。ssi模板标签将被移除。模板标签中的
if不再支持=比较运算符。将移除允许在没有
max_length参数的情况下定义Storage.get_available_name()和Storage.save()的向后兼容 shim。将移除在
ModelFormMixin.success_url中的传统%(<foo>)s语法支持。将移除
GeoQuerySet的聚合方法collect(),extent(),extent3d(),make_line(), 和unionagg()。将移除在创建内容类型实例时指定
ContentType.name的能力。将移除对旧版
allow_migrate签名的支持。它已从allow_migrate(self, db, model)更改为allow_migrate(self, db, app_label, model_name=None, **hints)。将移除使用逗号分隔参数的
{% cycle %}语法的支持。当给定无效的分隔符时,
Signer发出的警告将变为异常。
1.9¶
请查看 Django 1.7 发布说明 以获取有关这些更改的更多详细信息。
django.utils.dictconfig将被移除。django.utils.importlib将被移除。django.utils.tzinfo将被移除。django.utils.unittest将被移除。syncdb命令将被移除。django.db.models.signals.pre_syncdb和django.db.models.signals.post_syncdb将被移除。在数据库路由器上的
allow_syncdb将不再自动变成allow_migrate。将移除对没有迁移的应用程序的自动同步。除非您向
migrate传递--run-syncdb选项,否则所有应用程序将成为必须进行迁移。将移除没有迁移的应用程序的 SQL 管理命令,包括
sql、sqlall、sqlclear、sqldropindexes和sqlindexes。将移除对自动加载
initial_data固定数据和初始 SQL 数据的支持。所有模型都需要在一个已安装的应用程序中定义,或者声明一个显式的
app_label。此外,在其应用程序加载之前将无法导入它们。特别是,在其应用程序的根包中将无法导入模型。模型和表单中的
IPAddressField将被移除。为了与历史迁移兼容性,将保留一个存根字段。将不再支持
AppCommand.handle_app()。将不再能够从
django.contrib.sites.models导入RequestSite和get_current_site()。通过
runfcgi管理命令的 FastCGI 支持将被移除。请使用 WSGI 部署您的项目。django.utils.datastructures.SortedDict将被移除。请改用 Python 标准库中的collections.OrderedDict。ModelAdmin.declared_fieldsets将被移除。在 Django 代码库中,
util.py的实例已被重命名为utils.py,以统一所有 util 和 utils 引用。提供向后兼容性的模块将被移除:django.contrib.admin.utildjango.contrib.gis.db.backends.utildjango.db.backends.utildjango.forms.util
ModelAdmin.get_formsets将被移除。将移除为了将
BaseMemcachedCache._get_memcache_timeout()方法重命名为get_backend_timeout()而引入的向后兼容 shim。--natural和-n选项将被移除,用于dumpdata。serializers.serialize()的use_natural_keys参数将被移除。私有 API
django.forms.forms.get_declared_fields()将被移除。将移除使用
SplitDateTimeWidget与DateTimeField的能力。将移除
WSGIRequest.REQUEST属性。类
django.utils.datastructures.MergeDict将被移除。zh-cn和zh-tw语言代码将被移除,并分别被zh-hans和zh-hant语言代码替代。内部的
django.utils.functional.memoize将被移除。django.core.cache.get_cache将被移除。请在CACHES中添加适当的条目,并改用django.core.cache.caches。django.db.models.loading将被移除。将不再支持将可调用参数传递给查询集。
BaseCommand.requires_model_validation将被移除,取而代之的是requires_system_checks。管理验证器将被管理检查取代。ModelAdmin.validator_class和default_validator_class属性将被移除。ModelAdmin.validate()将被移除。django.db.backends.DatabaseValidation.validate_field将被移除,取而代之的是check_field方法。validate管理命令将被移除。django.utils.module_loading.import_by_path将被移除,取而代之的是django.utils.module_loading.import_string。`ssi``和`url``模板标签将从`future``模板标签库中删除(在1.3/1.4弃用期内使用)。
django.utils.text.javascript_quote将被移除。将不再支持数据库测试设置作为独立的数据库设置条目,以
TEST_为前缀。将移除对
ModelChoiceField和ModelMultipleChoiceField的cache_choices选项支持。RedirectView.permanent属性的默认值将从True更改为False。django.contrib.sitemaps.FlatPageSitemap将被移除,取而代之的是django.contrib.flatpages.sitemaps.FlatPageSitemap。私有 API
django.test.utils.TestTemplateLoader将被移除。django.contrib.contenttypes.generic模块将被移除。私有 API
django.db.models.sql.where.WhereNode.make_atom()和django.db.models.sql.where.Constraint将被移除。
1.8¶
请查看 Django 1.6 发布说明 以获取有关这些更改的更多详细信息。
django.contrib.comments将被移除。以下事务管理 API 将被移除:
TransactionMiddleware,在
django.db.transaction中定义的装饰器和上下文管理器autocommit、commit_on_success和commit_manually将被移除。在
django.db.transaction中定义的函数commit_unless_managed和rollback_unless_managed也将被移除。TRANSACTIONS_MANAGED设置也将被移除。
cycle和firstof模板标签将自动转义它们的参数。在 1.6 和 1.7 版本中,这一行为由位于future模板标签库中的这些标签的版本提供。SEND_BROKEN_LINK_EMAILS设置将被移除。请将django.middleware.common.BrokenLinkEmailsMiddleware中间件添加到你的MIDDLEWARE_CLASSES设置中。django.middleware.doc.XViewMiddleware将被移除。请改用django.contrib.admindocs.middleware.XViewMiddleware。Model._meta.module_name已重命名为model_name。移除了用于重命名
get_query_set和类似 queryset 方法的向后兼容的 shims。这影响到以下类:BaseModelAdmin、ChangeList、BaseCommentNode、GenericForeignKey、Manager、SingleRelatedObjectDescriptor和ReverseSingleRelatedObjectDescriptor。移除了用于重命名属性
ChangeList.root_query_set和ChangeList.query_set的向后兼容的 shims。django.views.defaults.shortcut将被移除,作为从核心 Django 代码库中移除所有django.contrib引用的目标的一部分。请改用django.contrib.contenttypes.views.shortcut。同时,django.conf.urls.shortcut也将被移除。对于 Python Imaging Library (PIL) 模块的支持将被移除,因为它似乎不再积极维护,并且不支持 Python 3。
以下私有 API 将被移除:
django.db.backenddjango.db.close_connection()django.db.backends.creation.BaseDatabaseCreation.set_autocommit()django.db.transaction.is_managed()django.db.transaction.managed()
django.forms.widgets.RadioInput将被移除,取而代之的是django.forms.widgets.RadioChoiceInput。模块
django.test.simple和类django.test.simple.DjangoTestSuiteRunner将被移除。请改用django.test.runner.DiscoverRunner。模块
django.test._doctest将被移除。请改用 Python 标准库中的 doctest 模块。CACHE_MIDDLEWARE_ANONYMOUS_ONLY设置将被移除。Usage of the hardcoded Hold down "Control", or "Command" on a Mac, to select more than one. string to override or append to user-provided
help_textin forms for ManyToMany model fields will not be performed by Django anymore either at the model or forms layer.Model._meta.get_(add|change|delete)_permission方法将被移除。会话键
django_language不再读取以保持向后兼容性。地理 Sitemaps 将被移除(
django.contrib.gis.sitemaps.views.index和django.contrib.gis.sitemaps.views.sitemap)。django.utils.html.fix_ampersands、fix_ampersands模板过滤器和django.utils.html.clean_html将在加速弃用后被移除。
1.7¶
请查看 Django 1.5 发布说明 以获取有关这些更改的更多详细信息。
模块
django.utils.simplejson将被移除。应该改用标准库中的json。函数``django.utils.itercompat.product`将被删除。应该使用Python内置版本。
当INSTALLED_APPS和TEMPLATE_DIRS设置被指定为普通字符串而不是元组时,它们的自动更正将被移除并引发异常。
mimetype参数将被从HttpResponse、SimpleTemplateResponse和TemplateResponse的__init__方法中移除。应该改用content_type。这也适用于render_to_response()快捷方式以及站点地图视图index()和sitemap()。当使用迭代器实例化
HttpResponse,或者当将content设置为迭代器时,该迭代器将被立即消耗。AUTH_PROFILE_MODULE设置以及 User 模型上的get_profile()方法将被移除。``cleanup``管理命令将被删除。它被``clearsessions``所取代。
daily_cleanup.py 脚本将会被移除。
depth关键字参数将从select_related()中移除。来自
django.test.utils的未记录文档的get_warnings_state()/restore_warnings_state()函数以及 django.test.*TestCase 中的save_warnings_state()/restore_warnings_state()方法已被弃用。应该使用从 Python 2.6 开始可用的warnings.catch_warnings上下文管理器。在
AuthenticationForm中未记录的check_for_test_cookie方法将在加速弃用后被移除。用户子类化这个表单的应该移除对这个方法的调用,并确保他们的身份验证相关视图启用了 CSRF 保护,以确保启用了 cookies。支持 base36 编码用户 ID(
django.contrib.auth.views.password_reset_confirm_uidb36)的django.contrib.auth.views.password_reset_confirm()版本将被移除。如果你的站点在 Django 1.6 上运行时间超过了PASSWORD_RESET_TIMEOUT_DAYS,这个更改不会产生影响。如果没有,那么在升级到 Django 1.7 之前生成的任何密码重置链接在升级后将不起作用。django.utils.encoding.StrAndUnicode混合类将被移除。
1.6¶
请查看 Django 1.4 发布说明 以获取有关这些更改的更多详细信息。
django.contrib.databrowse将来会被移除。django.contrib.localflavor将会被加快移除。django.contrib.markup将会被加快移除。兼容性模块
django.utils.copycompat和django.utils.hashcompat以及函数django.utils.itercompat.all和django.utils.itercompat.any将会被移除。应该使用Python内置版本。csrf_response_exempt和csrf_view_exempt装饰器将被删除。 从1.4开始,csrf_response_exempt已成为空操作(它返回相同的功能),而csrf_view_exempt已成为django.views.decorators.csrf.csrf_exempt的同义词以取代它。原有缓存后端
django.core.cache.backends.memcached.CacheClass后端在Django 1.3中分为两个,以引入对PyLibMC的支持。历史悠久的CacheClass将会被删除,取而代之的是缓存后端django.core.cache.backends.memcached.MemcachedCache。django.contrib.localflavor.uk的英国前缀对象只能通过其GB前缀名称来访问(GB是英国的正确ISO 3166代码)。IGNORABLE_404_STARTS和IGNORABLE_404_ENDS设置在 1.4 版本中已被IGNORABLE_404_URLS取代。它们将被移除。在 1.4 版本中,表单向导已经重构为使用基于类的视图,并具有可插拔的后端。之前的实现将被移除。
删除
cache_page()缓存的旧版调用方式。向后兼容的填充程序会自动向
'mail_admins'日志记录处理程序中添加一个debug-false过滤器。 如果需要的话,日志配置LOGGING配置应该显式地包括这个过滤器。内置的截断函数
django.utils.text.truncate_words()和django.utils.text.truncate_html_words()将被移除,取而代之的是django.utils.text.Truncator类。django.contrib.gis.geoip.GeoIP类在 1.4 版本中已移动到django.contrib.gis.geoip中,django.contrib.gis.utils中的快捷方式将被移除。django.conf.urls.defaults将被移除。函数include(),patterns(), 和url(),以及handler404和handler500现在可以通过django.conf.urls使用。函数
setup_environ()和execute_manager()将从django.core.management中移除。这也意味着旧的(1.4 版本之前的)manage.py文件的风格将不再起作用。不再支持将
is_safe和needs_autoescape标志设置为模板过滤器函数的属性。在 1.4 版本中,属性
HttpRequest.raw_post_data已重命名为HttpRequest.body。向后兼容性将被移除,HttpRequest.raw_post_data将不再起作用。在
ModelAdmin.response_add()中,post_url_continue参数的值必须是None``(以重定向到新创建的对象的编辑页面)或预格式化的 URL。不再接受字符串格式,例如之前的默认值 ``'../%s/'。
1.5¶
请查看 Django 1.3 发布说明 以获取有关这些更改的更多详细信息。
启动没有
SECRET_KEY的 Django 将引发异常而不是DeprecationWarning。这是从通常的弃用路径加速过来的(参见 Django 1.4 发布说明)。mod_python请求处理程序将被移除。应该改用mod_wsgi处理程序。django.test.client.Response对象上的template属性将被移除。应该改用templates属性。django.test.simple.DjangoTestRunner将被移除。而应该使用unittest的原生类。django.test.simple.DjangoTestRunner的功能(包括快速失败和 Ctrl-C 测试终止)可以由unittest.TextTestRunner提供。未记录的函数
django.contrib.formtools.utils.security_hash将被移除,应该改用django.contrib.formtools.utils.form_hmac。基于函数的通用视图模块将被移除,应该使用它们的基于类的等效模块,详情请参考 这里。
The
django.core.servers.basehttp.AdminMediaHandlerwill be removed. In its place usedjango.contrib.staticfiles.handlers.StaticFilesHandler.模板标签库
adminmedia和模板标签{% admin_media_prefix %}将被移除,取而代之的是通用的静态文件处理方式。(这比通常的弃用路径更快,参见 Django 1.4 发布说明。)url和ssi模板标签将被修改,使每个标签的第一个参数是一个模板变量,而不是隐含的字符串。在 1.4 版本中,这个行为由future模板标签库中的标签版本提供。reset和sqlreset管理命令将被移除。身份验证后端需要支持将非活动用户传递给处理权限的所有方法。不再检查
supports_inactive_user属性,并且可以从自定义后端中移除。在没有 SRID 值的几何体上调用
transform()将引发GEOSException。django.http.CompatCookie将被移除,应该使用django.http.SimpleCookie。django.core.context_processors.PermWrapper和django.core.context_processors.PermLookupDict将被移除,分别应该使用相应的django.contrib.auth.context_processors.PermWrapper和django.contrib.auth.context_processors.PermLookupDict。MEDIA_URL或STATIC_URL设置将需要以斜杠结尾,以确保在模板中有一种一致的方法来组合路径。django.db.models.fields.URLField.verify_exists将被移除。由于难以解决的安全和性能问题,该功能在 1.3.1 版本中已被弃用,并将遵循略微加速的弃用时间表。在运行时进行的翻译构建过程中,位于所谓的 项目路径 下的翻译将被忽略。可以使用
LOCALE_PATHS设置执行相同的任务,其中包括非应用程序特定翻译的文件系统路径,该路径包含在其值中的locale目录中。Markup contrib 应用程序将不再支持早于 2.1 版本的 Python-Markdown 库。由于这是与安全性相关的弃用,采用了加速的时间表。
CACHE_BACKEND设置将被移除。缓存后端应该在CACHES设置中指定。
1.4¶
请查看 Django 1.2 发布说明 以获取有关这些更改的更多详细信息。
CsrfResponseMiddlewareandCsrfMiddlewarewill be removed. Use the{% csrf_token %}template tag inside forms to enable CSRF protection.CsrfViewMiddlewareremains and is enabled by default.CSRF 功能的旧导入(
django.contrib.csrf.*)已在 1.2 版本中移动到核心,它们将被移除。django.contrib.gis.db.backend模块将被移除,取而代之的是特定的后端模块。SMTPConnection将被移除,取而代之的是通用的电子邮件后端 API。数据库后端上的许多对多 SQL 生成函数将被移除。
使用
DATABASE_*顶级设置来定义数据库连接的能力将被移除。使用简写符号来指定数据库后端(例如,
sqlite3而不是django.db.backends.sqlite3)的能力将被移除。get_db_prep_save、get_db_prep_value和get_db_prep_lookup方法将需要支持多个数据库。The
Messagemodel (indjango.contrib.auth), its related manager in theUsermodel (user.message_set), and the associated methods (user.message_set.create()anduser.get_and_delete_messages()), will be removed. The messages framework should be used instead. The relatedmessagesvariable returned by the auth context processor will also be removed. Note that this means that the admin application will depend on the messages context processor.身份验证后端需要支持
obj参数以进行权限检查。不再检查supports_object_permissions属性,可以从自定义后端中移除。Authentication backends will need to support the
AnonymousUserclass being passed to all methods dealing with permissions. Thesupports_anonymous_uservariable will no longer be checked and can be removed from custom backends.指定可调用模板加载器而不是
Loader类的能力将被移除,同时为了向后兼容性而包括在内置模板加载器中的load_template_source函数也将被移除。django.utils.translation.get_date_formats()和django.utils.translation.get_partial_date_formats()。这些函数将被移除;使用区域设置感知的django.utils.formats.get_format()来获取适当的格式。在
django.forms.fields中,常量:DEFAULT_DATE_INPUT_FORMATS、DEFAULT_TIME_INPUT_FORMATS和DEFAULT_DATETIME_INPUT_FORMATS将被移除。使用django.utils.formats.get_format()来获取适当的格式。将移除使用基于函数的测试运行器的能力,以及
django.test.simple.run_tests()测试运行器。django.contrib.syndication中的views.feed()视图和feeds.Feed类将被移除。应该改用基于类的视图views.Feed。django.core.context_processors.auth. This release will remove the old method in favor of the new method indjango.contrib.auth.context_processors.auth.postgresql数据库后端将被移除,应该改用postgresql_psycopg2后端。no语言代码将被移除,已被nb语言代码替代。身份验证后端需要定义布尔属性
supports_inactive_user,直到版本 1.5,届时将假定所有后端都能处理非活动用户。django.db.models.fields.XMLField将被移除。这在 1.3 版本中已被弃用。由于自从移除了oldforms后,该字段没有扮演任何角色,因此采用了加速的弃用时间表。所有使用XMLField的地方可以替换为TextField。django.core.files.storage.Storage(和其子类)的open()方法的未记录的mixin参数将被移除。
1.3¶
请查看 Django 1.1 发布说明 以获取有关这些更改的更多详细信息。
AdminSite.root(). This method of hooking up the admin URLs will be removed in favor of includingadmin.site.urls.身份验证后端需要在 1.4 版本之前定义布尔属性
supports_object_permissions和supports_anonymous_user,在此之后,将假定所有后端都支持这些选项。