Welcome to Django 2.0!
These release notes cover the new features, as well as some backwards incompatible changes you’ll want to be aware of when upgrading from Django 1.11 or earlier. We’ve dropped some features that have reached the end of their deprecation cycle, and we’ve begun the deprecation process for some features.
See the Upgrading Django to a newer version guide if you’re updating an existing project.
Django 2.0 supports Python 3.5+. Since Django 1.11, support for Python 2.7 and 3.4 is removed. We highly recommend and only officially support the latest release of each series.
Following the release of Django 2.0, we suggest that third-party app authors
drop support for all versions of Django prior to 1.11. At that time, you should
be able run your package’s tests using python -Wd so that deprecation
warnings do appear. After making the deprecation warning fixes, your app should
be compatible with Django 2.0.
django.contrib.auth¶django.contrib.postgres¶distinct argument for
ArrayAgg determines if
concatenated values will be distinct.date_attrs and time_attrs arguments for
SplitDateTimeWidget and
SplitHiddenDateTimeWidget allow specifying different
HTML attributes for the DateInput and TimeInput (or hidden)
subwidgets.LiveServerTestCase.To support native Python 2 strings, older Django versions had to accept both bytestrings and unicode strings. Now that Python 2 support is dropped, bytestrings should only be encountered around input/output boundaries (handling of binary fields or HTTP streams, for example). You might have to update your code to limit bytestring usage to a minimum, as Django no longer accepts bytestrings in certain code paths.
DatabaseOperations.datetime_cast_date_sql(),
datetime_cast_time_sql(), datetime_trunc_sql(), and
datetime_extract_sql() methods now return only the SQL to perform the
operation instead of SQL and a list of parameters.The end of upstream support for Oracle 11.2 is Dec. 2020. Django 1.11 will be supported until April 2020 which almost reaches this date. Django 2.0 officially supports Oracle 12.1+.
MySQL’s default isolation level, repeatable read, may cause data loss in
typical Django usage. To prevent that and for consistency with other databases,
the default isolation level is now read committed. You can use the
DATABASES setting to use a different isolation level, if needed.
AbstractUser.last_name max_length increased to 150¶A migration for django.contrib.auth.models.User.last_name is included.
If you have a custom user model inheriting from AbstractUser, you’ll need
to generate and apply a database migration for your user model.
If you want to preserve the 30 character limit for last names, use a custom form:
from django.contrib.auth.forms import UserChangeForm
class MyUserChangeForm(UserChangeForm):
last_name = forms.CharField(max_length=30, required=False)
If you wish to keep this restriction in the admin when editing users, set
UserAdmin.form to use this form:
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
class MyUserAdmin(UserAdmin):
form = MyUserChangeForm
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)
SessionAuthenticationMiddleware class is removed. It provided no
functionality since session authentication is unconditionally enabled in
Django 1.10.handler404, etc.) are now callables
instead of dotted Python path strings. Django favors callable references
since they provide better performance and debugging experience.django.db.backends.postgresql_psycopg2 module is deprecated in favor
of django.db.backends.postgresql. It’s been an alias since Django 1.9.
This only affects code that imports from the module directly. The
DATABASES setting can still use
'django.db.backends.postgresql_psycopg2', though you can simplify that by
using the 'django.db.backends.postgresql' name added in Django 1.9.django.shortcuts.render_to_response() is deprecated in favor of
django.shortcuts.render(). render() takes the same arguments
except that is also requires a request.DEFAULT_CONTENT_TYPE setting is deprecated. It doesn’t interact well
well with third-party apps and is obsolete since HTML5 has mostly superseded
XHTML.These features have reached the end of their deprecation cycle and are removed in Django 2.0. See Features deprecated in 1.9 and Features deprecated in 1.10 for details, including how to remove usage of these features.
weak argument to django.dispatch.signals.Signal.disconnect() is
removed.django.db.backends.base.BaseDatabaseOperations.check_aggregate_support()
is removed.django.forms.extras package is removed.assignment_tag helper is removed.host argument to SimpleTestCase.assertsRedirects() is removed.
The compatibility layer which allows absolute URLs to be considered equal to
relative ones when the path is identical is also removed.Field.rel and Field.remote_field.to are removed.on_delete argument for ForeignKey and OneToOneField are now
required.django.db.models.fields.add_lazy_relation() is removed.cursor.execute().django.contrib.auth.tests.utils.skipIfCustomUser() is removed.GeoManager and GeoQuerySet classes are removed.django.contrib.gis.geoip module is removed.supports_recursion check for template loaders is removed from: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 and load_template_sources template loader methods
are removed.template_dirs argument for template loaders is removed: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__() is removed.exception parameter
is removed.mime_type attribute of django.utils.feedgenerator.Atom1Feed and
django.utils.feedgenerator.RssFeed is removed.app_name argument to include() is removed.include() is
removed.Field._get_val_from_obj() is removed.django.template.loaders.eggs.Loader is removed.current_app parameter to the contrib.auth function-based views is
removed.callable_obj keyword argument to
SimpleTestCase.assertRaisesMessage() is removed.allow_tags attribute on ModelAdmin methods is
removed.enclosure keyword argument to SyndicationFeed.add_item() is
removed.django.template.loader.LoaderOrigin and
django.template.base.StringOrigin aliases for
django.template.base.Origin are removed.makemigrations --exit option is removed.get_srid() and set_srid() methods of
django.contrib.gis.geos.GEOSGeometry are removed.get_x(), set_x(), get_y(), set_y(), get_z(), and
set_z() methods of django.contrib.gis.geos.Point are removed.get_coords() and set_coords() methods of
django.contrib.gis.geos.Point are removed.cascaded_union property of django.contrib.gis.geos.MultiPolygon
is removed.django.utils.functional.allow_lazy() is removed.shell --plain option is removed.django.core.urlresolvers module is removed.CommaSeparatedIntegerField is removed, except for support in historical
migrations.Context.has_key() method is removed.django.core.files.storage.Storage.accessed_time(),
created_time(), and modified_time() methods is removed.Meta.default_related_name is set is removed.__search lookup is removed._apply_rel_filters() method is removed.User.is_authenticated() and User.is_anonymous() as methods
rather than properties is no longer supported.Model._meta.virtual_fields attribute is removed.virtual_only in Field.contribute_to_class() and
virtual in Model._meta.add_field() are removed.javascript_catalog() and json_catalog() views are removed.django.contrib.gis.utils.precision_wkt() is removed.OneToOneField to a
parent_link is removed.Widget._format_value() is removed.FileField methods get_directory_name() and get_filename() are
removed.mark_for_escaping() function and the classes it uses: EscapeData,
EscapeBytes, EscapeText, EscapeString, and EscapeUnicode are
removed.escape filter now uses django.utils.html.conditional_escape().Manager.use_for_related_fields is removed.Manager inheritance follows MRO inheritance rules. The requirement
to use Meta.manager_inheritance_from_future to opt-in to the behavior is
removed.settings.MIDDLEWARE_CLASSES is
removed.Feb 16, 2017