1. ========================
    
  2. Django 1.7 release notes
    
  3. ========================
    
  4. 
    
  5. *September 2, 2014*
    
  6. 
    
  7. Welcome to Django 1.7!
    
  8. 
    
  9. These release notes cover the :ref:`new features <whats-new-1.7>`, as well as
    
  10. some :ref:`backwards incompatible changes <backwards-incompatible-1.7>` you'll
    
  11. want to be aware of when upgrading from Django 1.6 or older versions. We've
    
  12. :ref:`begun the deprecation process for some features
    
  13. <deprecated-features-1.7>`, and some features have reached the end of their
    
  14. deprecation process and :ref:`have been removed <removed-features-1.7>`.
    
  15. 
    
  16. Python compatibility
    
  17. ====================
    
  18. 
    
  19. Django 1.7 requires Python 2.7, 3.2, 3.3, or 3.4. We **highly recommend** and
    
  20. only officially support the latest release of each series.
    
  21. 
    
  22. The Django 1.6 series is the last to support Python 2.6. Django 1.7 is the
    
  23. first release to support Python 3.4.
    
  24. 
    
  25. This change should affect only a small number of Django users, as most
    
  26. operating-system vendors today are shipping Python 2.7 or newer as their default
    
  27. version. If you're still using Python 2.6, however, you'll need to stick to
    
  28. Django 1.6 until you can upgrade your Python version. Per :doc:`our support
    
  29. policy </internals/release-process>`, Django 1.6 will continue to receive
    
  30. security support until the release of Django 1.8.
    
  31. 
    
  32. .. _whats-new-1.7:
    
  33. 
    
  34. What's new in Django 1.7
    
  35. ========================
    
  36. 
    
  37. Schema migrations
    
  38. -----------------
    
  39. 
    
  40. Django now has built-in support for schema migrations. It allows models
    
  41. to be updated, changed, and deleted by creating migration files that represent
    
  42. the model changes and which can be run on any development, staging or production
    
  43. database.
    
  44. 
    
  45. Migrations are covered in :doc:`their own documentation</topics/migrations>`,
    
  46. but a few of the key features are:
    
  47. 
    
  48. * ``syncdb`` has been deprecated and replaced by ``migrate``. Don't worry -
    
  49.   calls to ``syncdb`` will still work as before.
    
  50. 
    
  51. * A new ``makemigrations`` command provides an easy way to autodetect changes
    
  52.   to your models and make migrations for them.
    
  53. 
    
  54.   ``django.db.models.signals.pre_syncdb`` and
    
  55.   ``django.db.models.signals.post_syncdb`` have been deprecated,
    
  56.   to be replaced by :data:`~django.db.models.signals.pre_migrate` and
    
  57.   :data:`~django.db.models.signals.post_migrate` respectively. These
    
  58.   new signals have slightly different arguments. Check the
    
  59.   documentation for details.
    
  60. 
    
  61. * The ``allow_syncdb`` method on database routers is now called ``allow_migrate``,
    
  62.   but still performs the same function. Routers with ``allow_syncdb`` methods
    
  63.   will still work, but that method name is deprecated and you should change
    
  64.   it as soon as possible (nothing more than renaming is required).
    
  65. 
    
  66. * ``initial_data`` fixtures are no longer loaded for apps with migrations; if
    
  67.   you want to load initial data for an app, we suggest you create a migration for
    
  68.   your application and define a :class:`~django.db.migrations.operations.RunPython`
    
  69.   or :class:`~django.db.migrations.operations.RunSQL` operation in the ``operations`` section of the migration.
    
  70. 
    
  71. * Test rollback behavior is different for apps with migrations; in particular,
    
  72.   Django will no longer emulate rollbacks on non-transactional databases or
    
  73.   inside ``TransactionTestCase`` :ref:`unless specifically requested
    
  74.   <test-case-serialized-rollback>`.
    
  75. 
    
  76. * It is not advised to have apps without migrations depend on (have a
    
  77.   :class:`~django.db.models.ForeignKey` or
    
  78.   :class:`~django.db.models.ManyToManyField` to) apps with migrations.
    
  79. 
    
  80. .. _app-loading-refactor-17-release-note:
    
  81. 
    
  82. App-loading refactor
    
  83. --------------------
    
  84. 
    
  85. Historically, Django applications were tightly linked to models. A singleton
    
  86. known as the "app cache" dealt with both installed applications and models.
    
  87. The models module was used as an identifier for applications in many APIs.
    
  88. 
    
  89. As the concept of :doc:`Django applications </ref/applications>` matured, this
    
  90. code showed some shortcomings. It has been refactored into an "app registry"
    
  91. where models modules no longer have a central role and where it's possible to
    
  92. attach configuration data to applications.
    
  93. 
    
  94. Improvements thus far include:
    
  95. 
    
  96. * Applications can run code at startup, before Django does anything else, with
    
  97.   the :meth:`~django.apps.AppConfig.ready` method of their configuration.
    
  98. 
    
  99. * Application labels are assigned correctly to models even when they're
    
  100.   defined outside of ``models.py``. You don't have to set
    
  101.   :attr:`~django.db.models.Options.app_label` explicitly any more.
    
  102. 
    
  103. * It is possible to omit ``models.py`` entirely if an application doesn't
    
  104.   have any models.
    
  105. 
    
  106. * Applications can be relabeled with the :attr:`~django.apps.AppConfig.label`
    
  107.   attribute of application configurations, to work around label conflicts.
    
  108. 
    
  109. * The name of applications can be customized in the admin with the
    
  110.   :attr:`~django.apps.AppConfig.verbose_name` of application configurations.
    
  111. 
    
  112. * The admin automatically calls :func:`~django.contrib.admin.autodiscover()`
    
  113.   when Django starts. You can consequently remove this line from your
    
  114.   URLconf.
    
  115. 
    
  116. * Django imports all application configurations and models as soon as it
    
  117.   starts, through a deterministic and straightforward process. This should
    
  118.   make it easier to diagnose import issues such as import loops.
    
  119. 
    
  120. New method on Field subclasses
    
  121. ------------------------------
    
  122. 
    
  123. To help power both schema migrations and to enable easier addition of
    
  124. composite keys in future releases of Django, the
    
  125. :class:`~django.db.models.Field` API now has a new required method:
    
  126. ``deconstruct()``.
    
  127. 
    
  128. This method takes no arguments, and returns a tuple of four items:
    
  129. 
    
  130. * ``name``: The field's attribute name on its parent model, or ``None`` if it
    
  131.   is not part of a model
    
  132. * ``path``: A dotted, Python path to the class of this field, including the class name.
    
  133. * ``args``: Positional arguments, as a list
    
  134. * ``kwargs``: Keyword arguments, as a dict
    
  135. 
    
  136. These four values allow any field to be serialized into a file, as well as
    
  137. allowing the field to be copied safely, both essential parts of these new features.
    
  138. 
    
  139. This change should not affect you unless you write custom Field subclasses;
    
  140. if you do, you may need to reimplement the ``deconstruct()`` method if your
    
  141. subclass changes the method signature of ``__init__`` in any way. If your
    
  142. field just inherits from a built-in Django field and doesn't override ``__init__``,
    
  143. no changes are necessary.
    
  144. 
    
  145. If you do need to override ``deconstruct()``, a good place to start is the
    
  146. built-in Django fields (``django/db/models/fields/__init__.py``) as several
    
  147. fields, including ``DecimalField`` and ``DateField``, override it and show how
    
  148. to call the method on the superclass and simply add or remove extra arguments.
    
  149. 
    
  150. This also means that all arguments to fields must themselves be serializable;
    
  151. to see what we consider serializable, and to find out how to make your own
    
  152. classes serializable, read the
    
  153. :ref:`migration serialization documentation <migration-serializing>`.
    
  154. 
    
  155. Calling custom ``QuerySet`` methods from the ``Manager``
    
  156. --------------------------------------------------------
    
  157. 
    
  158. Historically, the recommended way to make reusable model queries was to create
    
  159. methods on a custom ``Manager`` class. The problem with this approach was that
    
  160. after the first method call, you'd get back a ``QuerySet`` instance and
    
  161. couldn't call additional custom manager methods.
    
  162. 
    
  163. Though not documented, it was common to work around this issue by creating a
    
  164. custom ``QuerySet`` so that custom methods could be chained; but the solution
    
  165. had a number of drawbacks:
    
  166. 
    
  167. * The custom ``QuerySet`` and its custom methods were lost after the first
    
  168.   call to ``values()`` or ``values_list()``.
    
  169. 
    
  170. * Writing a custom ``Manager`` was still necessary to return the custom
    
  171.   ``QuerySet`` class and all methods that were desired on the ``Manager``
    
  172.   had to be proxied to the ``QuerySet``. The whole process went against
    
  173.   the DRY principle.
    
  174. 
    
  175. The :meth:`QuerySet.as_manager() <django.db.models.query.QuerySet.as_manager>`
    
  176. class method can now directly :ref:`create Manager with QuerySet methods
    
  177. <create-manager-with-queryset-methods>`::
    
  178. 
    
  179.     class FoodQuerySet(models.QuerySet):
    
  180.         def pizzas(self):
    
  181.             return self.filter(kind='pizza')
    
  182. 
    
  183.         def vegetarian(self):
    
  184.             return self.filter(vegetarian=True)
    
  185. 
    
  186.     class Food(models.Model):
    
  187.         kind = models.CharField(max_length=50)
    
  188.         vegetarian = models.BooleanField(default=False)
    
  189.         objects = FoodQuerySet.as_manager()
    
  190. 
    
  191.     Food.objects.pizzas().vegetarian()
    
  192. 
    
  193. Using a custom manager when traversing reverse relations
    
  194. --------------------------------------------------------
    
  195. 
    
  196. It is now possible to :ref:`specify a custom manager
    
  197. <using-custom-reverse-manager>` when traversing a reverse relationship::
    
  198. 
    
  199.     class Blog(models.Model):
    
  200.         pass
    
  201. 
    
  202.     class Entry(models.Model):
    
  203.         blog = models.ForeignKey(Blog)
    
  204. 
    
  205.         objects = models.Manager()  # Default Manager
    
  206.         entries = EntryManager()    # Custom Manager
    
  207. 
    
  208.     b = Blog.objects.get(id=1)
    
  209.     b.entry_set(manager='entries').all()
    
  210. 
    
  211. New system check framework
    
  212. --------------------------
    
  213. 
    
  214. We've added a new :doc:`System check framework </ref/checks>` for
    
  215. detecting common problems (like invalid models) and providing hints for
    
  216. resolving those problems. The framework is extensible so you can add your
    
  217. own checks for your own apps and libraries.
    
  218. 
    
  219. To perform system checks, you use the :djadmin:`check` management command.
    
  220. This command replaces the older ``validate`` management command.
    
  221. 
    
  222. New ``Prefetch`` object for advanced ``prefetch_related`` operations.
    
  223. ---------------------------------------------------------------------
    
  224. 
    
  225. The new :class:`~django.db.models.Prefetch` object allows customizing
    
  226. prefetch operations.
    
  227. 
    
  228. You can specify the ``QuerySet`` used to traverse a given relation
    
  229. or customize the storage location of prefetch results.
    
  230. 
    
  231. This enables things like filtering prefetched relations, calling
    
  232. :meth:`~django.db.models.query.QuerySet.select_related()` from a prefetched
    
  233. relation, or prefetching the same relation multiple times with different
    
  234. querysets. See :meth:`~django.db.models.query.QuerySet.prefetch_related()`
    
  235. for more details.
    
  236. 
    
  237. Admin shortcuts support time zones
    
  238. ----------------------------------
    
  239. 
    
  240. The "today" and "now" shortcuts next to date and time input widgets in the
    
  241. admin are now operating in the :ref:`current time zone
    
  242. <default-current-time-zone>`. Previously, they used the browser time zone,
    
  243. which could result in saving the wrong value when it didn't match the current
    
  244. time zone on the server.
    
  245. 
    
  246. In addition, the widgets now display a help message when the browser and
    
  247. server time zone are different, to clarify how the value inserted in the field
    
  248. will be interpreted.
    
  249. 
    
  250. Using database cursors as context managers
    
  251. ------------------------------------------
    
  252. 
    
  253. Prior to Python 2.7, database cursors could be used as a context manager. The
    
  254. specific backend's cursor defined the behavior of the context manager. The
    
  255. behavior of magic method lookups was changed with Python 2.7 and cursors were
    
  256. no longer usable as context managers.
    
  257. 
    
  258. Django 1.7 allows a cursor to be used as a context manager. That is,
    
  259. the following can be used::
    
  260. 
    
  261.     with connection.cursor() as c:
    
  262.         c.execute(...)
    
  263. 
    
  264. instead of::
    
  265. 
    
  266.     c = connection.cursor()
    
  267.     try:
    
  268.         c.execute(...)
    
  269.     finally:
    
  270.         c.close()
    
  271. 
    
  272. Custom lookups
    
  273. --------------
    
  274. 
    
  275. It is now possible to write custom lookups and transforms for the ORM.
    
  276. Custom lookups work just like Django's built-in lookups (e.g. ``lte``,
    
  277. ``icontains``) while transforms are a new concept.
    
  278. 
    
  279. The :class:`django.db.models.Lookup` class provides a way to add lookup
    
  280. operators for model fields. As an example it is possible to add ``day_lte``
    
  281. operator for ``DateFields``.
    
  282. 
    
  283. The :class:`django.db.models.Transform` class allows transformations of
    
  284. database values prior to the final lookup. For example it is possible to
    
  285. write a ``year`` transform that extracts year from the field's value.
    
  286. Transforms allow for chaining. After the ``year`` transform has been added
    
  287. to ``DateField`` it is possible to filter on the transformed value, for
    
  288. example ``qs.filter(author__birthdate__year__lte=1981)``.
    
  289. 
    
  290. For more information about both custom lookups and transforms refer to
    
  291. the :doc:`custom lookups </howto/custom-lookups>` documentation.
    
  292. 
    
  293. Improvements to ``Form`` error handling
    
  294. ---------------------------------------
    
  295. 
    
  296. ``Form.add_error()``
    
  297. ~~~~~~~~~~~~~~~~~~~~
    
  298. 
    
  299. Previously there were two main patterns for handling errors in forms:
    
  300. 
    
  301. * Raising a :exc:`~django.core.exceptions.ValidationError` from within certain
    
  302.   functions (e.g. ``Field.clean()``, ``Form.clean_<fieldname>()``, or
    
  303.   ``Form.clean()`` for non-field errors.)
    
  304. 
    
  305. * Fiddling with ``Form._errors`` when targeting a specific field in
    
  306.   ``Form.clean()`` or adding errors from outside of a "clean" method
    
  307.   (e.g. directly from a view).
    
  308. 
    
  309. Using the former pattern was straightforward since the form can guess from the
    
  310. context (i.e. which method raised the exception) where the errors belong and
    
  311. automatically process them. This remains the canonical way of adding errors
    
  312. when possible. However the latter was fiddly and error-prone, since the burden
    
  313. of handling edge cases fell on the user.
    
  314. 
    
  315. The new :meth:`~django.forms.Form.add_error()` method allows adding errors
    
  316. to specific form fields from anywhere without having to worry about the details
    
  317. such as creating instances of ``django.forms.utils.ErrorList`` or dealing with
    
  318. ``Form.cleaned_data``. This new API replaces manipulating ``Form._errors``
    
  319. which now becomes a private API.
    
  320. 
    
  321. See :ref:`validating-fields-with-clean` for an example using
    
  322. ``Form.add_error()``.
    
  323. 
    
  324. Error metadata
    
  325. ~~~~~~~~~~~~~~
    
  326. 
    
  327. The :exc:`~django.core.exceptions.ValidationError` constructor accepts metadata
    
  328. such as error ``code`` or ``params`` which are then available for interpolating
    
  329. into the error message (see :ref:`raising-validation-error` for more details);
    
  330. however, before Django 1.7 those metadata were discarded as soon as the errors
    
  331. were added to :attr:`Form.errors <django.forms.Form.errors>`.
    
  332. 
    
  333. :attr:`Form.errors <django.forms.Form.errors>` and
    
  334. ``django.forms.utils.ErrorList`` now store the ``ValidationError`` instances
    
  335. so these metadata can be retrieved at any time through the new
    
  336. :meth:`Form.errors.as_data <django.forms.Form.errors.as_data()>` method.
    
  337. 
    
  338. The retrieved ``ValidationError`` instances can then be identified thanks to
    
  339. their error ``code`` which enables things like rewriting the error's message
    
  340. or writing custom logic in a view when a given error is present. It can also
    
  341. be used to serialize the errors in a custom format such as XML.
    
  342. 
    
  343. The new :meth:`Form.errors.as_json() <django.forms.Form.errors.as_json()>`
    
  344. method is a convenience method which returns error messages along with error
    
  345. codes serialized as JSON. ``as_json()`` uses ``as_data()`` and gives an idea
    
  346. of how the new system could be extended.
    
  347. 
    
  348. Error containers and backward compatibility
    
  349. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  350. 
    
  351. Heavy changes to the various error containers were necessary in order
    
  352. to support the features above, specifically
    
  353. :attr:`Form.errors <django.forms.Form.errors>`,
    
  354. ``django.forms.utils.ErrorList``, and the internal storages of
    
  355. :exc:`~django.core.exceptions.ValidationError`. These containers which used
    
  356. to store error strings now store ``ValidationError`` instances and public APIs
    
  357. have been adapted to make this as transparent as possible, but if you've been
    
  358. using private APIs, some of the changes are backwards incompatible; see
    
  359. :ref:`validation-error-constructor-and-internal-storage` for more details.
    
  360. 
    
  361. Minor features
    
  362. --------------
    
  363. 
    
  364. :mod:`django.contrib.admin`
    
  365. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  366. 
    
  367. * You can now implement :attr:`~django.contrib.admin.AdminSite.site_header`,
    
  368.   :attr:`~django.contrib.admin.AdminSite.site_title`, and
    
  369.   :attr:`~django.contrib.admin.AdminSite.index_title` attributes on a custom
    
  370.   :class:`~django.contrib.admin.AdminSite` in order to easily change the admin
    
  371.   site's page title and header text. No more needing to override templates!
    
  372. 
    
  373. * Buttons in :mod:`django.contrib.admin` now use the ``border-radius`` CSS
    
  374.   property for rounded corners rather than GIF background images.
    
  375. 
    
  376. * Some admin templates now have ``app-<app_name>`` and ``model-<model_name>``
    
  377.   classes in their ``<body>`` tag to allow customizing the CSS per app or per
    
  378.   model.
    
  379. 
    
  380. * The admin changelist cells now have a ``field-<field_name>`` class in the
    
  381.   HTML to enable style customizations.
    
  382. 
    
  383. * The admin's search fields can now be customized per-request thanks to the new
    
  384.   :meth:`django.contrib.admin.ModelAdmin.get_search_fields` method.
    
  385. 
    
  386. * The :meth:`ModelAdmin.get_fields()
    
  387.   <django.contrib.admin.ModelAdmin.get_fields>` method may be overridden to
    
  388.   customize the value of :attr:`ModelAdmin.fields
    
  389.   <django.contrib.admin.ModelAdmin.fields>`.
    
  390. 
    
  391. * In addition to the existing ``admin.site.register`` syntax, you can use the
    
  392.   new :func:`~django.contrib.admin.register` decorator to register a
    
  393.   :class:`~django.contrib.admin.ModelAdmin`.
    
  394. 
    
  395. * You may specify :meth:`ModelAdmin.list_display_links
    
  396.   <django.contrib.admin.ModelAdmin.list_display_links>` ``= None`` to disable
    
  397.   links on the change list page grid.
    
  398. 
    
  399. * You may now specify :attr:`ModelAdmin.view_on_site
    
  400.   <django.contrib.admin.ModelAdmin.view_on_site>` to control whether or not to
    
  401.   display the "View on site" link.
    
  402. 
    
  403. * You can specify a descending ordering for a :attr:`ModelAdmin.list_display
    
  404.   <django.contrib.admin.ModelAdmin.list_display>` value by prefixing the
    
  405.   ``admin_order_field`` value with a hyphen.
    
  406. 
    
  407. * The :meth:`ModelAdmin.get_changeform_initial_data()
    
  408.   <django.contrib.admin.ModelAdmin.get_changeform_initial_data>` method may be
    
  409.   overridden to define custom behavior for setting initial change form data.
    
  410. 
    
  411. :mod:`django.contrib.auth`
    
  412. ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  413. 
    
  414. * Any ``**kwargs`` passed to
    
  415.   :meth:`~django.contrib.auth.models.User.email_user()` are passed to the
    
  416.   underlying :meth:`~django.core.mail.send_mail()` call.
    
  417. 
    
  418. * The :func:`~django.contrib.auth.decorators.permission_required` decorator can
    
  419.   take a list of permissions as well as a single permission.
    
  420. 
    
  421. * You can override the new :meth:`AuthenticationForm.confirm_login_allowed()
    
  422.   <django.contrib.auth.forms.AuthenticationForm.confirm_login_allowed>` method
    
  423.   to more easily customize the login policy.
    
  424. 
    
  425. * ``django.contrib.auth.views.password_reset()`` takes an optional
    
  426.   ``html_email_template_name`` parameter used to send a multipart HTML email
    
  427.   for password resets.
    
  428. 
    
  429. * The :meth:`AbstractBaseUser.get_session_auth_hash()
    
  430.   <django.contrib.auth.models.AbstractBaseUser.get_session_auth_hash>`
    
  431.   method was added and if your :setting:`AUTH_USER_MODEL` inherits from
    
  432.   :class:`~django.contrib.auth.models.AbstractBaseUser`, changing a user's
    
  433.   password now invalidates old sessions if the
    
  434.   ``django.contrib.auth.middleware.SessionAuthenticationMiddleware`` is
    
  435.   enabled. See :ref:`session-invalidation-on-password-change` for more details.
    
  436. 
    
  437. ``django.contrib.formtools``
    
  438. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  439. 
    
  440. * Calls to ``WizardView.done()`` now include a ``form_dict`` to allow easier
    
  441.   access to forms by their step name.
    
  442. 
    
  443. :mod:`django.contrib.gis`
    
  444. ~~~~~~~~~~~~~~~~~~~~~~~~~
    
  445. 
    
  446. * The default OpenLayers library version included in widgets has been updated
    
  447.   from 2.11 to 2.13.
    
  448. 
    
  449. * Prepared geometries now also support the ``crosses``, ``disjoint``,
    
  450.   ``overlaps``, ``touches`` and ``within`` predicates, if GEOS 3.3 or later is
    
  451.   installed.
    
  452. 
    
  453. :mod:`django.contrib.messages`
    
  454. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  455. 
    
  456. * The backends for :mod:`django.contrib.messages` that use cookies, will now
    
  457.   follow the :setting:`SESSION_COOKIE_SECURE` and
    
  458.   :setting:`SESSION_COOKIE_HTTPONLY` settings.
    
  459. 
    
  460. * The :ref:`messages context processor <message-displaying>` now adds a
    
  461.   dictionary of default levels under the name ``DEFAULT_MESSAGE_LEVELS``.
    
  462. 
    
  463. * :class:`~django.contrib.messages.storage.base.Message` objects now have a
    
  464.   ``level_tag`` attribute that contains the string representation of the
    
  465.   message level.
    
  466. 
    
  467. :mod:`django.contrib.redirects`
    
  468. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  469. 
    
  470. * :class:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware`
    
  471.   has two new attributes
    
  472.   (:attr:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_gone_class`
    
  473.   and
    
  474.   :attr:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_redirect_class`)
    
  475.   that specify the types of :class:`~django.http.HttpResponse` instances the
    
  476.   middleware returns.
    
  477. 
    
  478. :mod:`django.contrib.sessions`
    
  479. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  480. 
    
  481. * The ``"django.contrib.sessions.backends.cached_db"`` session backend now
    
  482.   respects :setting:`SESSION_CACHE_ALIAS`. In previous versions, it always used
    
  483.   the ``default`` cache.
    
  484. 
    
  485. :mod:`django.contrib.sitemaps`
    
  486. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  487. 
    
  488. * The :mod:`sitemap framework<django.contrib.sitemaps>` now makes use of
    
  489.   :attr:`~django.contrib.sitemaps.Sitemap.lastmod` to set a ``Last-Modified``
    
  490.   header in the response. This makes it possible for the
    
  491.   :class:`~django.middleware.http.ConditionalGetMiddleware` to handle
    
  492.   conditional ``GET`` requests for sitemaps which set ``lastmod``.
    
  493. 
    
  494. :mod:`django.contrib.sites`
    
  495. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  496. 
    
  497. * The new :class:`django.contrib.sites.middleware.CurrentSiteMiddleware` allows
    
  498.   setting the current site on each request.
    
  499. 
    
  500. :mod:`django.contrib.staticfiles`
    
  501. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  502. 
    
  503. * The :ref:`static files storage classes <staticfiles-storages>` may be
    
  504.   subclassed to override the permissions that collected static files and
    
  505.   directories receive by setting the
    
  506.   :attr:`~django.core.files.storage.FileSystemStorage.file_permissions_mode`
    
  507.   and :attr:`~django.core.files.storage.FileSystemStorage.directory_permissions_mode`
    
  508.   parameters. See :djadmin:`collectstatic` for example usage.
    
  509. 
    
  510. * The ``CachedStaticFilesStorage`` backend gets a sibling class called
    
  511.   :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`
    
  512.   that doesn't use the cache system at all but instead a JSON file called
    
  513.   ``staticfiles.json`` for storing the mapping between the original file name
    
  514.   (e.g. ``css/styles.css``) and the hashed file name (e.g.
    
  515.   ``css/styles.55e7cbb9ba48.css``). The ``staticfiles.json`` file is created
    
  516.   when running the :djadmin:`collectstatic` management command and should
    
  517.   be a less expensive alternative for remote storages such as Amazon S3.
    
  518. 
    
  519.   See the :class:`~django.contrib.staticfiles.storage.ManifestStaticFilesStorage`
    
  520.   docs for more information.
    
  521. 
    
  522. * :djadmin:`findstatic` now accepts verbosity flag level 2, meaning it will
    
  523.   show the relative paths of the directories it searched. See
    
  524.   :djadmin:`findstatic` for example output.
    
  525. 
    
  526. :mod:`django.contrib.syndication`
    
  527. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  528. 
    
  529. * The :class:`~django.utils.feedgenerator.Atom1Feed` syndication feed's
    
  530.   ``updated`` element now utilizes ``updateddate`` instead of ``pubdate``,
    
  531.   allowing the ``published`` element to be included in the feed (which
    
  532.   relies on ``pubdate``).
    
  533. 
    
  534. Cache
    
  535. ~~~~~
    
  536. 
    
  537. * Access to caches configured in :setting:`CACHES` is now available via
    
  538.   :data:`django.core.cache.caches`. This dict-like object provides a different
    
  539.   instance per thread. It supersedes ``django.core.cache.get_cache()`` which
    
  540.   is now deprecated.
    
  541. 
    
  542. * If you instantiate cache backends directly, be aware that they aren't
    
  543.   thread-safe any more, as :data:`django.core.cache.caches` now yields
    
  544.   different instances per thread.
    
  545. 
    
  546. * Defining the :setting:`TIMEOUT <CACHES-TIMEOUT>` argument of the
    
  547.   :setting:`CACHES` setting as ``None`` will set the cache keys as
    
  548.   "non-expiring" by default. Previously, it was only possible to pass
    
  549.   ``timeout=None`` to the cache backend's ``set()`` method.
    
  550. 
    
  551. Cross Site Request Forgery
    
  552. ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  553. 
    
  554. * The :setting:`CSRF_COOKIE_AGE` setting facilitates the use of session-based
    
  555.   CSRF cookies.
    
  556. 
    
  557. Email
    
  558. ~~~~~
    
  559. 
    
  560. * :func:`~django.core.mail.send_mail` now accepts an ``html_message``
    
  561.   parameter for sending a multipart :mimetype:`text/plain` and
    
  562.   :mimetype:`text/html` email.
    
  563. 
    
  564. * The SMTP :class:`~django.core.mail.backends.smtp.EmailBackend` now accepts a
    
  565.   ``timeout`` parameter.
    
  566. 
    
  567. File Storage
    
  568. ~~~~~~~~~~~~
    
  569. 
    
  570. * File locking on Windows previously depended on the PyWin32 package; if it
    
  571.   wasn't installed, file locking failed silently. That dependency has been
    
  572.   removed, and file locking is now implemented natively on both Windows
    
  573.   and Unix.
    
  574. 
    
  575. File Uploads
    
  576. ~~~~~~~~~~~~
    
  577. 
    
  578. * The new :attr:`UploadedFile.content_type_extra
    
  579.   <django.core.files.uploadedfile.UploadedFile.content_type_extra>` attribute
    
  580.   contains extra parameters passed to the ``content-type`` header on a file
    
  581.   upload.
    
  582. 
    
  583. * The new :setting:`FILE_UPLOAD_DIRECTORY_PERMISSIONS` setting controls
    
  584.   the file system permissions of directories created during file upload, like
    
  585.   :setting:`FILE_UPLOAD_PERMISSIONS` does for the files themselves.
    
  586. 
    
  587. * The :attr:`FileField.upload_to <django.db.models.FileField.upload_to>`
    
  588.   attribute is now optional. If it is omitted or given ``None`` or an empty
    
  589.   string, a subdirectory won't be used for storing the uploaded files.
    
  590. 
    
  591. * Uploaded files are now explicitly closed before the response is delivered to
    
  592.   the client. Partially uploaded files are also closed as long as they are
    
  593.   named ``file`` in the upload handler.
    
  594. 
    
  595. * :meth:`Storage.get_available_name()
    
  596.   <django.core.files.storage.Storage.get_available_name>` now appends an
    
  597.   underscore plus a random 7 character alphanumeric string (e.g.
    
  598.   ``"_x3a1gho"``), rather than iterating through an underscore followed by a
    
  599.   number (e.g. ``"_1"``, ``"_2"``, etc.) to prevent a denial-of-service attack.
    
  600.   This change was also made in the 1.6.6, 1.5.9, and 1.4.14 security releases.
    
  601. 
    
  602. Forms
    
  603. ~~~~~
    
  604. 
    
  605. * The ``<label>`` and ``<input>`` tags rendered by
    
  606.   :class:`~django.forms.RadioSelect` and
    
  607.   :class:`~django.forms.CheckboxSelectMultiple` when looping over the radio
    
  608.   buttons or checkboxes now include ``for`` and ``id`` attributes, respectively.
    
  609.   Each radio button or checkbox includes an ``id_for_label`` attribute to
    
  610.   output the element's ID.
    
  611. 
    
  612. * The ``<textarea>`` tags rendered by :class:`~django.forms.Textarea` now
    
  613.   include a ``maxlength`` attribute if the :class:`~django.db.models.TextField`
    
  614.   model field has a ``max_length``.
    
  615. 
    
  616. * :attr:`Field.choices<django.db.models.Field.choices>` now allows you to
    
  617.   customize the "empty choice" label by including a tuple with an empty string
    
  618.   or ``None`` for the key and the custom label as the value. The default blank
    
  619.   option ``"----------"`` will be omitted in this case.
    
  620. 
    
  621. * :class:`~django.forms.MultiValueField` allows optional subfields by setting
    
  622.   the ``require_all_fields`` argument to ``False``. The ``required`` attribute
    
  623.   for each individual field will be respected, and a new ``incomplete``
    
  624.   validation error will be raised when any required fields are empty.
    
  625. 
    
  626. * The :meth:`~django.forms.Form.clean` method on a form no longer needs to
    
  627.   return ``self.cleaned_data``. If it does return a changed dictionary then
    
  628.   that will still be used.
    
  629. 
    
  630. * After a temporary regression in Django 1.6, it's now possible again to make
    
  631.   :class:`~django.forms.TypedChoiceField` ``coerce`` method return an arbitrary
    
  632.   value.
    
  633. 
    
  634. * :attr:`SelectDateWidget.months
    
  635.   <django.forms.SelectDateWidget.months>` can be used to
    
  636.   customize the wording of the months displayed in the select widget.
    
  637. 
    
  638. * The ``min_num`` and ``validate_min`` parameters were added to
    
  639.   :func:`~django.forms.formsets.formset_factory` to allow validating
    
  640.   a minimum number of submitted forms.
    
  641. 
    
  642. * The metaclasses used by ``Form`` and ``ModelForm`` have been reworked to
    
  643.   support more inheritance scenarios. The previous limitation that prevented
    
  644.   inheriting from both ``Form`` and ``ModelForm`` simultaneously have been
    
  645.   removed as long as ``ModelForm`` appears first in the MRO.
    
  646. 
    
  647. * It's now possible to remove a field from a ``Form`` when subclassing by
    
  648.   setting the name to ``None``.
    
  649. 
    
  650. * It's now possible to customize the error messages for ``ModelForm``’s
    
  651.   ``unique``, ``unique_for_date``, and ``unique_together`` constraints.
    
  652.   In order to support ``unique_together`` or any other ``NON_FIELD_ERROR``,
    
  653.   ``ModelForm`` now looks for the ``NON_FIELD_ERROR`` key in the
    
  654.   ``error_messages`` dictionary of the ``ModelForm``’s inner ``Meta`` class.
    
  655.   See :ref:`considerations regarding model's error_messages
    
  656.   <considerations-regarding-model-errormessages>` for more details.
    
  657. 
    
  658. Internationalization
    
  659. ~~~~~~~~~~~~~~~~~~~~
    
  660. 
    
  661. * The :attr:`django.middleware.locale.LocaleMiddleware.response_redirect_class`
    
  662.   attribute allows you to customize the redirects issued by the middleware.
    
  663. 
    
  664. * The :class:`~django.middleware.locale.LocaleMiddleware` now stores the user's
    
  665.   selected language with the session key ``_language``. This should only be
    
  666.   accessed using the ``LANGUAGE_SESSION_KEY`` constant. Previously it was
    
  667.   stored with the key ``django_language`` and the ``LANGUAGE_SESSION_KEY``
    
  668.   constant did not exist, but keys reserved for Django should start with an
    
  669.   underscore. For backwards compatibility ``django_language`` is still read
    
  670.   from in 1.7. Sessions will be migrated to the new key as they are written.
    
  671. 
    
  672. * The :ttag:`blocktrans` tag now supports a ``trimmed`` option. This
    
  673.   option will remove newline characters from the beginning and the end of the
    
  674.   content of the ``{% blocktrans %}`` tag, replace any whitespace at the
    
  675.   beginning and end of a line and merge all lines into one using a space
    
  676.   character to separate them. This is quite useful for indenting the content of
    
  677.   a ``{% blocktrans %}`` tag without having the indentation characters end up
    
  678.   in the corresponding entry in the ``.po`` file, which makes the translation
    
  679.   process easier.
    
  680. 
    
  681. * When you run :djadmin:`makemessages` from the root directory of your project,
    
  682.   any extracted strings will now be automatically distributed to the proper
    
  683.   app or project message file. See :ref:`how-to-create-language-files` for
    
  684.   details.
    
  685. 
    
  686. * The :djadmin:`makemessages` command now always adds the ``--previous``
    
  687.   command line flag to the ``msgmerge`` command, keeping previously translated
    
  688.   strings in ``.po`` files for fuzzy strings.
    
  689. 
    
  690. * The following settings to adjust the language cookie options were introduced:
    
  691.   :setting:`LANGUAGE_COOKIE_AGE`, :setting:`LANGUAGE_COOKIE_DOMAIN`
    
  692.   and :setting:`LANGUAGE_COOKIE_PATH`.
    
  693. 
    
  694. * Added :doc:`/topics/i18n/formatting` for Esperanto.
    
  695. 
    
  696. Management Commands
    
  697. ~~~~~~~~~~~~~~~~~~~
    
  698. 
    
  699. * The new :option:`--no-color` option for ``django-admin`` disables the
    
  700.   colorization of management command output.
    
  701. 
    
  702. * The new :option:`dumpdata --natural-foreign` and :option:`dumpdata
    
  703.   --natural-primary` options, and the new ``use_natural_foreign_keys`` and
    
  704.   ``use_natural_primary_keys`` arguments for ``serializers.serialize()``, allow
    
  705.   the use of natural primary keys when serializing.
    
  706. 
    
  707. * It is no longer necessary to provide the cache table name or the
    
  708.   ``--database`` option for the :djadmin:`createcachetable` command.
    
  709.   Django takes this information from your settings file. If you have configured
    
  710.   multiple caches or multiple databases, all cache tables are created.
    
  711. 
    
  712. * The :djadmin:`runserver` command received several improvements:
    
  713. 
    
  714.   * On Linux systems, if pyinotify_ is installed, the development server will
    
  715.     reload immediately when a file is changed. Previously, it polled the
    
  716.     filesystem for changes every second. That caused a small delay before
    
  717.     reloads and reduced battery life on laptops.
    
  718. 
    
  719.     .. _pyinotify: https://pypi.org/project/pyinotify/
    
  720. 
    
  721.   * In addition, the development server automatically reloads when a
    
  722.     translation file is updated, i.e. after running
    
  723.     :djadmin:`compilemessages`.
    
  724. 
    
  725.   * All HTTP requests are logged to the console, including requests for static
    
  726.     files or ``favicon.ico`` that used to be filtered out.
    
  727. 
    
  728. * Management commands can now produce syntax colored output under Windows if
    
  729.   the ANSICON third-party tool is installed and active.
    
  730. 
    
  731. * :djadmin:`collectstatic` command with symlink option is now supported on
    
  732.   Windows NT 6 (Windows Vista and newer).
    
  733. 
    
  734. * Initial SQL data now works better if the sqlparse_ Python library is
    
  735.   installed.
    
  736. 
    
  737.   Note that it's deprecated in favor of the
    
  738.   :class:`~django.db.migrations.operations.RunSQL` operation of migrations,
    
  739.   which benefits from the improved behavior.
    
  740. 
    
  741. .. _sqlparse: https://pypi.org/project/sqlparse/
    
  742. 
    
  743. Models
    
  744. ~~~~~~
    
  745. 
    
  746. * The :meth:`QuerySet.update_or_create()
    
  747.   <django.db.models.query.QuerySet.update_or_create>` method was added.
    
  748. 
    
  749. * The new :attr:`~django.db.models.Options.default_permissions` model
    
  750.   ``Meta`` option allows you to customize (or disable) creation of the default
    
  751.   add, change, and delete permissions.
    
  752. 
    
  753. * Explicit :class:`~django.db.models.OneToOneField` for
    
  754.   :ref:`multi-table-inheritance` are now discovered in abstract classes.
    
  755. 
    
  756. * It is now possible to avoid creating a backward relation for
    
  757.   :class:`~django.db.models.OneToOneField` by setting its
    
  758.   :attr:`~django.db.models.ForeignKey.related_name` to
    
  759.   ``'+'`` or ending it with ``'+'``.
    
  760. 
    
  761. * :class:`F expressions <django.db.models.F>` support the power operator
    
  762.   (``**``).
    
  763. 
    
  764. * The ``remove()`` and ``clear()`` methods of the related managers created by
    
  765.   ``ForeignKey`` and ``GenericForeignKey`` now accept the ``bulk`` keyword
    
  766.   argument to control whether or not to perform operations in bulk
    
  767.   (i.e. using ``QuerySet.update()``). Defaults to ``True``.
    
  768. 
    
  769. * It is now possible to use ``None`` as a query value for the :lookup:`iexact`
    
  770.   lookup.
    
  771. 
    
  772. * It is now possible to pass a callable as value for the attribute
    
  773.   :attr:`~django.db.models.ForeignKey.limit_choices_to` when defining a
    
  774.   ``ForeignKey`` or ``ManyToManyField``.
    
  775. 
    
  776. * Calling :meth:`only() <django.db.models.query.QuerySet.only>` and
    
  777.   :meth:`defer() <django.db.models.query.QuerySet.defer>` on the result of
    
  778.   :meth:`QuerySet.values() <django.db.models.query.QuerySet.values>` now raises
    
  779.   an error (before that, it would either result in a database error or
    
  780.   incorrect data).
    
  781. 
    
  782. * You can use a single list for :attr:`~django.db.models.Options.index_together`
    
  783.   (rather than a list of lists) when specifying a single set of fields.
    
  784. 
    
  785. * Custom intermediate models having more than one foreign key to any of the
    
  786.   models participating in a many-to-many relationship are now permitted,
    
  787.   provided you explicitly specify which foreign keys should be used by setting
    
  788.   the new :attr:`ManyToManyField.through_fields <django.db.models.ManyToManyField.through_fields>`
    
  789.   argument.
    
  790. 
    
  791. * Assigning a model instance to a non-relation field will now throw an error.
    
  792.   Previously this used to work if the field accepted integers as input as it
    
  793.   took the primary key.
    
  794. 
    
  795. * Integer fields are now validated against database backend specific min and
    
  796.   max values based on their :meth:`internal_type <django.db.models.Field.get_internal_type>`.
    
  797.   Previously model field validation didn't prevent values out of their associated
    
  798.   column data type range from being saved resulting in an integrity error.
    
  799. 
    
  800. * It is now possible to explicitly :meth:`~django.db.models.query.QuerySet.order_by`
    
  801.   a relation ``_id`` field by using its attribute name.
    
  802. 
    
  803. Signals
    
  804. ~~~~~~~
    
  805. 
    
  806. * The ``enter`` argument was added to the
    
  807.   :data:`~django.test.signals.setting_changed` signal.
    
  808. 
    
  809. * The model signals can be now be connected to using a ``str`` of the
    
  810.   ``'app_label.ModelName'`` form – just like related fields – to lazily
    
  811.   reference their senders.
    
  812. 
    
  813. Templates
    
  814. ~~~~~~~~~
    
  815. 
    
  816. * The :meth:`Context.push() <django.template.Context.push>` method now returns
    
  817.   a context manager which automatically calls :meth:`pop()
    
  818.   <django.template.Context.pop>` upon exiting the ``with`` statement.
    
  819.   Additionally, :meth:`push() <django.template.Context.push>` now accepts
    
  820.   parameters that are passed to the ``dict`` constructor used to build the new
    
  821.   context level.
    
  822. 
    
  823. * The new :meth:`Context.flatten() <django.template.Context.flatten>` method
    
  824.   returns a ``Context``'s stack as one flat dictionary.
    
  825. 
    
  826. * ``Context`` objects can now be compared for equality (internally, this
    
  827.   uses :meth:`Context.flatten() <django.template.Context.flatten>` so the
    
  828.   internal structure of each ``Context``'s stack doesn't matter as long as their
    
  829.   flattened version is identical).
    
  830. 
    
  831. * The :ttag:`widthratio` template tag now accepts an ``"as"`` parameter to
    
  832.   capture the result in a variable.
    
  833. 
    
  834. * The :ttag:`include` template tag will now also accept anything with a
    
  835.   ``render()`` method (such as a ``Template``) as an argument. String
    
  836.   arguments will be looked up using
    
  837.   :func:`~django.template.loader.get_template` as always.
    
  838. 
    
  839. * It is now possible to :ttag:`include` templates recursively.
    
  840. 
    
  841. * Template objects now have an origin attribute set when
    
  842.   ``TEMPLATE_DEBUG`` is ``True``. This allows template origins to be
    
  843.   inspected and logged outside of the ``django.template`` infrastructure.
    
  844. 
    
  845. * ``TypeError`` exceptions are no longer silenced when raised during the
    
  846.   rendering of a template.
    
  847. 
    
  848. * The following functions now accept a ``dirs`` parameter which is a list or
    
  849.   tuple to override ``TEMPLATE_DIRS``:
    
  850. 
    
  851.   * :func:`django.template.loader.get_template()`
    
  852.   * :func:`django.template.loader.select_template()`
    
  853.   * :func:`django.shortcuts.render()`
    
  854.   * ``django.shortcuts.render_to_response()``
    
  855. 
    
  856. * The :tfilter:`time` filter now accepts timezone-related :ref:`format
    
  857.   specifiers <date-and-time-formatting-specifiers>` ``'e'``, ``'O'`` , ``'T'``
    
  858.   and ``'Z'`` and is able to digest :ref:`time-zone-aware
    
  859.   <naive_vs_aware_datetimes>` ``datetime`` instances performing the expected
    
  860.   rendering.
    
  861. 
    
  862. * The :ttag:`cache` tag will now try to use the cache called
    
  863.   "template_fragments" if it exists and fall back to using the default cache
    
  864.   otherwise. It also now accepts an optional ``using`` keyword argument to
    
  865.   control which cache it uses.
    
  866. 
    
  867. * The new :tfilter:`truncatechars_html` filter truncates a string to be no
    
  868.   longer than the specified number of characters, taking HTML into account.
    
  869. 
    
  870. Requests and Responses
    
  871. ~~~~~~~~~~~~~~~~~~~~~~
    
  872. 
    
  873. * The new :attr:`HttpRequest.scheme <django.http.HttpRequest.scheme>` attribute
    
  874.   specifies the scheme of the request (``http`` or ``https`` normally).
    
  875. 
    
  876. 
    
  877. * The shortcut :func:`redirect() <django.shortcuts.redirect>` now supports
    
  878.   relative URLs.
    
  879. 
    
  880. * The new :class:`~django.http.JsonResponse` subclass of
    
  881.   :class:`~django.http.HttpResponse` helps easily create JSON-encoded responses.
    
  882. 
    
  883. Tests
    
  884. ~~~~~
    
  885. 
    
  886. * :class:`~django.test.runner.DiscoverRunner` has two new attributes,
    
  887.   :attr:`~django.test.runner.DiscoverRunner.test_suite` and
    
  888.   :attr:`~django.test.runner.DiscoverRunner.test_runner`, which facilitate
    
  889.   overriding the way tests are collected and run.
    
  890. 
    
  891. * The ``fetch_redirect_response`` argument was added to
    
  892.   :meth:`~django.test.SimpleTestCase.assertRedirects`. Since the test
    
  893.   client can't fetch externals URLs, this allows you to use ``assertRedirects``
    
  894.   with redirects that aren't part of your Django app.
    
  895. 
    
  896. * Correct handling of scheme when making comparisons in
    
  897.   :meth:`~django.test.SimpleTestCase.assertRedirects`.
    
  898. 
    
  899. * The ``secure`` argument was added to all the request methods of
    
  900.   :class:`~django.test.Client`. If ``True``, the request will be made
    
  901.   through HTTPS.
    
  902. 
    
  903. * :meth:`~django.test.TransactionTestCase.assertNumQueries` now prints
    
  904.   out the list of executed queries if the assertion fails.
    
  905. 
    
  906. * The ``WSGIRequest`` instance generated by the test handler is now attached to
    
  907.   the :attr:`django.test.Response.wsgi_request` attribute.
    
  908. 
    
  909. * The database settings for testing have been collected into a dictionary
    
  910.   named :setting:`TEST <DATABASE-TEST>`.
    
  911. 
    
  912. Utilities
    
  913. ~~~~~~~~~
    
  914. 
    
  915. * Improved :func:`~django.utils.html.strip_tags` accuracy (but it still cannot
    
  916.   guarantee an HTML-safe result, as stated in the documentation).
    
  917. 
    
  918. Validators
    
  919. ~~~~~~~~~~
    
  920. 
    
  921. * :class:`~django.core.validators.RegexValidator` now accepts the optional
    
  922.   :attr:`~django.core.validators.RegexValidator.flags` and
    
  923.   Boolean :attr:`~django.core.validators.RegexValidator.inverse_match` arguments.
    
  924.   The :attr:`~django.core.validators.RegexValidator.inverse_match` attribute
    
  925.   determines if the :exc:`~django.core.exceptions.ValidationError` should
    
  926.   be raised when the regular expression pattern matches (``True``) or does not
    
  927.   match (``False``, by default) the provided ``value``. The
    
  928.   :attr:`~django.core.validators.RegexValidator.flags` attribute sets the flags
    
  929.   used when compiling a regular expression string.
    
  930. 
    
  931. * :class:`~django.core.validators.URLValidator` now accepts an optional
    
  932.   ``schemes`` argument which allows customization of the accepted URI schemes
    
  933.   (instead of the defaults ``http(s)`` and ``ftp(s)``).
    
  934. 
    
  935. * :func:`~django.core.validators.validate_email` now accepts addresses with
    
  936.   IPv6 literals, like ``example@[2001:db8::1]``, as specified in RFC 5321.
    
  937. 
    
  938. .. _backwards-incompatible-1.7:
    
  939. 
    
  940. Backwards incompatible changes in 1.7
    
  941. =====================================
    
  942. 
    
  943. .. warning::
    
  944. 
    
  945.     In addition to the changes outlined in this section, be sure to review the
    
  946.     :ref:`deprecation plan <deprecation-removed-in-1.7>` for any features that
    
  947.     have been removed. If you haven't updated your code within the
    
  948.     deprecation timeline for a given feature, its removal may appear as a
    
  949.     backwards incompatible change.
    
  950. 
    
  951. ``allow_syncdb`` / ``allow_migrate``
    
  952. ------------------------------------
    
  953. 
    
  954. While Django will still look at ``allow_syncdb`` methods even though they
    
  955. should be renamed to ``allow_migrate``, there is a subtle difference in which
    
  956. models get passed to these methods.
    
  957. 
    
  958. For apps with migrations, ``allow_migrate`` will now get passed
    
  959. :ref:`historical models <historical-models>`, which are special versioned models
    
  960. without custom attributes, methods or managers. Make sure your ``allow_migrate``
    
  961. methods are only referring to fields or other items in ``model._meta``.
    
  962. 
    
  963. initial_data
    
  964. ------------
    
  965. 
    
  966. Apps with migrations will not load ``initial_data`` fixtures when they have
    
  967. finished migrating. Apps without migrations will continue to load these fixtures
    
  968. during the phase of ``migrate`` which emulates the old ``syncdb`` behavior,
    
  969. but any new apps will not have this support.
    
  970. 
    
  971. Instead, you are encouraged to load initial data in migrations if you need it
    
  972. (using the ``RunPython`` operation and your model classes);
    
  973. this has the added advantage that your initial data will not need updating
    
  974. every time you change the schema.
    
  975. 
    
  976. Additionally, like the rest of Django's old ``syncdb`` code, ``initial_data``
    
  977. has been started down the deprecation path and will be removed in Django 1.9.
    
  978. 
    
  979. ``deconstruct()`` and serializability
    
  980. -------------------------------------
    
  981. 
    
  982. Django now requires all Field classes and all of their constructor arguments
    
  983. to be serializable. If you modify the constructor signature in your custom
    
  984. Field in any way, you'll need to implement a ``deconstruct()`` method;
    
  985. we've expanded the custom field documentation with :ref:`instructions
    
  986. on implementing this method <custom-field-deconstruct-method>`.
    
  987. 
    
  988. The requirement for all field arguments to be
    
  989. :ref:`serializable <migration-serializing>` means that any custom class
    
  990. instances being passed into Field constructors - things like custom Storage
    
  991. subclasses, for instance - need to have a :ref:`deconstruct method defined on
    
  992. them as well <custom-deconstruct-method>`, though Django provides a handy
    
  993. class decorator that will work for most applications.
    
  994. 
    
  995. App-loading changes
    
  996. -------------------
    
  997. 
    
  998. Start-up sequence
    
  999. ~~~~~~~~~~~~~~~~~
    
  1000. 
    
  1001. Django 1.7 loads application configurations and models as soon as it starts.
    
  1002. While this behavior is more straightforward and is believed to be more robust,
    
  1003. regressions cannot be ruled out. See :ref:`applications-troubleshooting` for
    
  1004. solutions to some problems you may encounter.
    
  1005. 
    
  1006. Standalone scripts
    
  1007. ~~~~~~~~~~~~~~~~~~
    
  1008. 
    
  1009. If you're using Django in a plain Python script — rather than a management
    
  1010. command — and you rely on the :envvar:`DJANGO_SETTINGS_MODULE` environment
    
  1011. variable, you must now explicitly initialize Django at the beginning of your
    
  1012. script with::
    
  1013. 
    
  1014.     >>> import django
    
  1015.     >>> django.setup()
    
  1016. 
    
  1017. Otherwise, you will hit an ``AppRegistryNotReady`` exception.
    
  1018. 
    
  1019. WSGI scripts
    
  1020. ~~~~~~~~~~~~
    
  1021. 
    
  1022. Until Django 1.3, the recommended way to create a WSGI application was::
    
  1023. 
    
  1024.     import django.core.handlers.wsgi
    
  1025.     application = django.core.handlers.wsgi.WSGIHandler()
    
  1026. 
    
  1027. In Django 1.4, support for WSGI was improved and the API changed to::
    
  1028. 
    
  1029.     from django.core.wsgi import get_wsgi_application
    
  1030.     application = get_wsgi_application()
    
  1031. 
    
  1032. If you're still using the former style in your WSGI script, you need to
    
  1033. upgrade to the latter, or you will hit an ``AppRegistryNotReady`` exception.
    
  1034. 
    
  1035. App registry consistency
    
  1036. ~~~~~~~~~~~~~~~~~~~~~~~~
    
  1037. 
    
  1038. It is no longer possible to have multiple installed applications with the same
    
  1039. label. In previous versions of Django, this didn't always work correctly, but
    
  1040. didn't crash outright either.
    
  1041. 
    
  1042. If you have two apps with the same label, you should create an
    
  1043. :class:`~django.apps.AppConfig` for one of them and override its
    
  1044. :class:`~django.apps.AppConfig.label` there. You should then adjust your code
    
  1045. wherever it references this application or its models with the old label.
    
  1046. 
    
  1047. It isn't possible to import the same model twice through different paths any
    
  1048. more. As of Django 1.6, this may happen only if you're manually putting a
    
  1049. directory and a subdirectory on :envvar:`PYTHONPATH`. Refer to the section on
    
  1050. the new project layout in the :doc:`1.4 release notes </releases/1.4>` for
    
  1051. migration instructions.
    
  1052. 
    
  1053. You should make sure that:
    
  1054. 
    
  1055. * All models are defined in applications that are listed in
    
  1056.   :setting:`INSTALLED_APPS` or have an explicit
    
  1057.   :attr:`~django.db.models.Options.app_label`.
    
  1058. 
    
  1059. * Models aren't imported as a side-effect of loading their application.
    
  1060.   Specifically, you shouldn't import models in the root module of an
    
  1061.   application nor in the module that define its configuration class.
    
  1062. 
    
  1063. Django will enforce these requirements as of version 1.9, after a deprecation
    
  1064. period.
    
  1065. 
    
  1066. Subclassing AppCommand
    
  1067. ~~~~~~~~~~~~~~~~~~~~~~
    
  1068. 
    
  1069. Subclasses of :class:`~django.core.management.AppCommand` must now implement a
    
  1070. :meth:`~django.core.management.AppCommand.handle_app_config` method instead of
    
  1071. ``handle_app()``. This method receives an :class:`~django.apps.AppConfig`
    
  1072. instance instead of a models module.
    
  1073. 
    
  1074. Introspecting applications
    
  1075. ~~~~~~~~~~~~~~~~~~~~~~~~~~
    
  1076. 
    
  1077. Since :setting:`INSTALLED_APPS` now supports application configuration classes
    
  1078. in addition to application modules, you should review code that accesses this
    
  1079. setting directly and use the app registry (:attr:`django.apps.apps`) instead.
    
  1080. 
    
  1081. The app registry has preserved some features of the old app cache. Even though
    
  1082. the app cache was a private API, obsolete methods and arguments will be
    
  1083. removed through a standard deprecation path, with the exception of the
    
  1084. following changes that take effect immediately:
    
  1085. 
    
  1086. * ``get_model`` raises :exc:`LookupError` instead of returning ``None`` when no
    
  1087.   model is found.
    
  1088. 
    
  1089. * The ``only_installed`` argument of ``get_model`` and ``get_models`` no
    
  1090.   longer exists, nor does the ``seed_cache`` argument of ``get_model``.
    
  1091. 
    
  1092. Management commands and order of :setting:`INSTALLED_APPS`
    
  1093. ----------------------------------------------------------
    
  1094. 
    
  1095. When several applications provide management commands with the same name,
    
  1096. Django loads the command from the application that comes first in
    
  1097. :setting:`INSTALLED_APPS`. Previous versions loaded the command from the
    
  1098. application that came last.
    
  1099. 
    
  1100. This brings discovery of management commands in line with other parts of
    
  1101. Django that rely on the order of :setting:`INSTALLED_APPS`, such as static
    
  1102. files, templates, and translations.
    
  1103. 
    
  1104. .. _validation-error-constructor-and-internal-storage:
    
  1105. 
    
  1106. ``ValidationError`` constructor and internal storage
    
  1107. ----------------------------------------------------
    
  1108. 
    
  1109. The behavior of the ``ValidationError`` constructor has changed when it
    
  1110. receives a container of errors as an argument (e.g. a ``list`` or an
    
  1111. ``ErrorList``):
    
  1112. 
    
  1113. * It converts any strings it finds to instances of ``ValidationError``
    
  1114.   before adding them to its internal storage.
    
  1115. 
    
  1116. * It doesn't store the given container but rather copies its content to its
    
  1117.   own internal storage; previously the container itself was added to the
    
  1118.   ``ValidationError`` instance and used as internal storage.
    
  1119. 
    
  1120. This means that if you access the ``ValidationError`` internal storages, such
    
  1121. as ``error_list``; ``error_dict``; or the return value of
    
  1122. ``update_error_dict()`` you may find instances of ``ValidationError`` where you
    
  1123. would have previously found strings.
    
  1124. 
    
  1125. Also if you directly assigned the return value of ``update_error_dict()``
    
  1126. to ``Form._errors`` you may inadvertently add ``list`` instances where
    
  1127. ``ErrorList`` instances are expected. This is a problem because unlike a
    
  1128. simple ``list``, an ``ErrorList`` knows how to handle instances of
    
  1129. ``ValidationError``.
    
  1130. 
    
  1131. Most use-cases that warranted using these private APIs are now covered by
    
  1132. the newly introduced :meth:`Form.add_error() <django.forms.Form.add_error()>`
    
  1133. method::
    
  1134. 
    
  1135.     # Old pattern:
    
  1136.     try:
    
  1137.         # ...
    
  1138.     except ValidationError as e:
    
  1139.         self._errors = e.update_error_dict(self._errors)
    
  1140. 
    
  1141.     # New pattern:
    
  1142.     try:
    
  1143.         # ...
    
  1144.     except ValidationError as e:
    
  1145.         self.add_error(None, e)
    
  1146. 
    
  1147. If you need both Django <= 1.6 and 1.7 compatibility you can't use
    
  1148. :meth:`Form.add_error() <django.forms.Form.add_error()>` since it
    
  1149. wasn't available before Django 1.7, but you can use the following
    
  1150. workaround to convert any ``list`` into ``ErrorList``::
    
  1151. 
    
  1152.     try:
    
  1153.         # ...
    
  1154.     except ValidationError as e:
    
  1155.         self._errors = e.update_error_dict(self._errors)
    
  1156. 
    
  1157.     # Additional code to ensure ``ErrorDict`` is exclusively
    
  1158.     # composed of ``ErrorList`` instances.
    
  1159.     for field, error_list in self._errors.items():
    
  1160.         if not isinstance(error_list, self.error_class):
    
  1161.             self._errors[field] = self.error_class(error_list)
    
  1162. 
    
  1163. Behavior of ``LocMemCache`` regarding pickle errors
    
  1164. ---------------------------------------------------
    
  1165. 
    
  1166. An inconsistency existed in previous versions of Django regarding how pickle
    
  1167. errors are handled by different cache backends.
    
  1168. ``django.core.cache.backends.locmem.LocMemCache`` used to fail silently when
    
  1169. such an error occurs, which is inconsistent with other backends and leads to
    
  1170. cache-specific errors. This has been fixed in Django 1.7, see
    
  1171. :ticket:`21200` for more details.
    
  1172. 
    
  1173. Cache keys are now generated from the request's absolute URL
    
  1174. ------------------------------------------------------------
    
  1175. 
    
  1176. Previous versions of Django generated cache keys using a request's path and
    
  1177. query string but not the scheme or host. If a Django application was serving
    
  1178. multiple subdomains or domains, cache keys could collide. In Django 1.7, cache
    
  1179. keys vary by the absolute URL of the request including scheme, host, path, and
    
  1180. query string. For example, the URL portion of a cache key is now generated from
    
  1181. ``https://www.example.com/path/to/?key=val`` rather than ``/path/to/?key=val``.
    
  1182. The cache keys generated by Django 1.7 will be different from the keys
    
  1183. generated by older versions of Django. After upgrading to Django 1.7, the first
    
  1184. request to any previously cached URL will be a cache miss.
    
  1185. 
    
  1186. Passing ``None`` to ``Manager.db_manager()``
    
  1187. --------------------------------------------
    
  1188. 
    
  1189. In previous versions of Django, it was possible to use
    
  1190. ``db_manager(using=None)`` on a model manager instance to obtain a manager
    
  1191. instance using default routing behavior, overriding any manually specified
    
  1192. database routing. In Django 1.7, a value of ``None`` passed to db_manager will
    
  1193. produce a router that *retains* any manually assigned database routing -- the
    
  1194. manager will *not* be reset. This was necessary to resolve an inconsistency in
    
  1195. the way routing information cascaded over joins. See :ticket:`13724` for more
    
  1196. details.
    
  1197. 
    
  1198. ``pytz`` may be required
    
  1199. ------------------------
    
  1200. 
    
  1201. If your project handles datetimes before 1970 or after 2037 and Django raises
    
  1202. a :exc:`ValueError` when encountering them, you will have to install pytz_. You
    
  1203. may be affected by this problem if you use Django's time zone-related date
    
  1204. formats or :mod:`django.contrib.syndication`.
    
  1205. 
    
  1206. .. _pytz: https://pypi.org/project/pytz/
    
  1207. 
    
  1208. ``remove()`` and ``clear()`` methods of related managers
    
  1209. --------------------------------------------------------
    
  1210. 
    
  1211. The ``remove()`` and ``clear()`` methods of the related managers created by
    
  1212. ``ForeignKey``, ``GenericForeignKey``, and ``ManyToManyField`` suffered from a
    
  1213. number of issues. Some operations ran multiple data modifying queries without
    
  1214. wrapping them in a transaction, and some operations didn't respect default
    
  1215. filtering when it was present (i.e. when the default manager on the related
    
  1216. model implemented a custom ``get_queryset()``).
    
  1217. 
    
  1218. Fixing the issues introduced some backward incompatible changes:
    
  1219. 
    
  1220. - The default implementation of ``remove()`` for ``ForeignKey`` related managers
    
  1221.   changed from a series of ``Model.save()`` calls to a single
    
  1222.   ``QuerySet.update()`` call. The change means that ``pre_save`` and
    
  1223.   ``post_save`` signals aren't sent anymore. You can use the ``bulk=False``
    
  1224.   keyword argument to revert to the previous behavior.
    
  1225. 
    
  1226. - The ``remove()`` and ``clear()`` methods for ``GenericForeignKey`` related
    
  1227.   managers now perform bulk delete. The ``Model.delete()`` method isn't called
    
  1228.   on each instance anymore. You can use the ``bulk=False`` keyword argument to
    
  1229.   revert to the previous behavior.
    
  1230. 
    
  1231. - The ``remove()`` and ``clear()`` methods for ``ManyToManyField`` related
    
  1232.   managers perform nested queries when filtering is involved, which may or
    
  1233.   may not be an issue depending on your database and your data itself.
    
  1234.   See :ref:`this note <nested-queries-performance>` for more details.
    
  1235. 
    
  1236. Admin login redirection strategy
    
  1237. --------------------------------
    
  1238. 
    
  1239. Historically, the Django admin site passed the request from an unauthorized or
    
  1240. unauthenticated user directly to the login view, without HTTP redirection. In
    
  1241. Django 1.7, this behavior changed to conform to a more traditional workflow
    
  1242. where any unauthorized request to an admin page will be redirected (by HTTP
    
  1243. status code 302) to the login page, with the ``next`` parameter set to the
    
  1244. referring path. The user will be redirected there after a successful login.
    
  1245. 
    
  1246. Note also that the admin login form has been updated to not contain the
    
  1247. ``this_is_the_login_form`` field (now unused) and the ``ValidationError`` code
    
  1248. has been set to the more regular ``invalid_login`` key.
    
  1249. 
    
  1250. ``select_for_update()`` requires a transaction
    
  1251. ----------------------------------------------
    
  1252. 
    
  1253. Historically, queries that use
    
  1254. :meth:`~django.db.models.query.QuerySet.select_for_update()` could be
    
  1255. executed in autocommit mode, outside of a transaction. Before Django
    
  1256. 1.6, Django's automatic transactions mode allowed this to be used to
    
  1257. lock records until the next write operation. Django 1.6 introduced
    
  1258. database-level autocommit; since then, execution in such a context
    
  1259. voids the effect of ``select_for_update()``. It is, therefore, assumed
    
  1260. now to be an error and raises an exception.
    
  1261. 
    
  1262. This change was made because such errors can be caused by including an
    
  1263. app which expects global transactions (e.g. :setting:`ATOMIC_REQUESTS
    
  1264. <DATABASE-ATOMIC_REQUESTS>` set to ``True``), or Django's old autocommit
    
  1265. behavior, in a project which runs without them; and further, such
    
  1266. errors may manifest as data-corruption bugs. It was also made in
    
  1267. Django 1.6.3.
    
  1268. 
    
  1269. This change may cause test failures if you use ``select_for_update()``
    
  1270. in a test class which is a subclass of
    
  1271. :class:`~django.test.TransactionTestCase` rather than
    
  1272. :class:`~django.test.TestCase`.
    
  1273. 
    
  1274. Contrib middleware removed from default ``MIDDLEWARE_CLASSES``
    
  1275. --------------------------------------------------------------
    
  1276. 
    
  1277. The :ref:`app-loading refactor <app-loading-refactor-17-release-note>`
    
  1278. deprecated using models from apps which are not part of the
    
  1279. :setting:`INSTALLED_APPS` setting. This exposed an incompatibility between
    
  1280. the default :setting:`INSTALLED_APPS` and ``MIDDLEWARE_CLASSES`` in the
    
  1281. global defaults (``django.conf.global_settings``). To bring these settings in
    
  1282. sync and prevent deprecation warnings when doing things like testing reusable
    
  1283. apps with minimal settings,
    
  1284. :class:`~django.contrib.sessions.middleware.SessionMiddleware`,
    
  1285. :class:`~django.contrib.auth.middleware.AuthenticationMiddleware`, and
    
  1286. :class:`~django.contrib.messages.middleware.MessageMiddleware` were removed
    
  1287. from the defaults. These classes will still be included in the default settings
    
  1288. generated by :djadmin:`startproject`. Most projects will not be affected by
    
  1289. this change but if you were not previously declaring the
    
  1290. ``MIDDLEWARE_CLASSES`` in your project settings and relying on the
    
  1291. global default you should ensure that the new defaults are in line with your
    
  1292. project's needs. You should also check for any code that accesses
    
  1293. ``django.conf.global_settings.MIDDLEWARE_CLASSES`` directly.
    
  1294. 
    
  1295. Miscellaneous
    
  1296. -------------
    
  1297. 
    
  1298. * The :meth:`django.core.files.uploadhandler.FileUploadHandler.new_file()`
    
  1299.   method is now passed an additional ``content_type_extra`` parameter. If you
    
  1300.   have a custom :class:`~django.core.files.uploadhandler.FileUploadHandler`
    
  1301.   that implements ``new_file()``, be sure it accepts this new parameter.
    
  1302. 
    
  1303. * :class:`ModelFormSet<django.forms.models.BaseModelFormSet>`\s no longer
    
  1304.   delete instances when ``save(commit=False)`` is called. See
    
  1305.   :attr:`~django.forms.formsets.BaseFormSet.can_delete` for instructions on how
    
  1306.   to manually delete objects from deleted forms.
    
  1307. 
    
  1308. * Loading empty fixtures emits a ``RuntimeWarning`` rather than raising
    
  1309.   :exc:`~django.core.management.CommandError`.
    
  1310. 
    
  1311. * :func:`django.contrib.staticfiles.views.serve` will now raise an
    
  1312.   :exc:`~django.http.Http404` exception instead of
    
  1313.   :exc:`~django.core.exceptions.ImproperlyConfigured` when :setting:`DEBUG`
    
  1314.   is ``False``. This change removes the need to conditionally add the view to
    
  1315.   your root URLconf, which in turn makes it safe to reverse by name. It also
    
  1316.   removes the ability for visitors to generate spurious HTTP 500 errors by
    
  1317.   requesting static files that don't exist or haven't been collected yet.
    
  1318. 
    
  1319. * The :meth:`django.db.models.Model.__eq__` method is now defined in a
    
  1320.   way where instances of a proxy model and its base model are considered
    
  1321.   equal when primary keys match. Previously only instances of exact same
    
  1322.   class were considered equal on primary key match.
    
  1323. 
    
  1324. * The :meth:`django.db.models.Model.__eq__` method has changed such that
    
  1325.   two ``Model`` instances without primary key values won't be considered
    
  1326.   equal (unless they are the same instance).
    
  1327. 
    
  1328. * The :meth:`django.db.models.Model.__hash__` method will now raise ``TypeError``
    
  1329.   when called on an instance without a primary key value. This is done to
    
  1330.   avoid mutable ``__hash__`` values in containers.
    
  1331. 
    
  1332. * :class:`~django.db.models.AutoField` columns in SQLite databases will now be
    
  1333.   created using the ``AUTOINCREMENT`` option, which guarantees monotonic
    
  1334.   increments. This will cause primary key numbering behavior to change on
    
  1335.   SQLite, becoming consistent with most other SQL databases. This will only
    
  1336.   apply to newly created tables. If you have a database created with an older
    
  1337.   version of Django, you will need to migrate it to take advantage of this
    
  1338.   feature. For example, you could do the following:
    
  1339. 
    
  1340.   #) Use :djadmin:`dumpdata` to save your data.
    
  1341.   #) Rename the existing database file (keep it as a backup).
    
  1342.   #) Run :djadmin:`migrate` to create the updated schema.
    
  1343.   #) Use :djadmin:`loaddata` to import the fixtures you exported in (1).
    
  1344. 
    
  1345. * ``django.contrib.auth.models.AbstractUser`` no longer defines a
    
  1346.   :meth:`~django.db.models.Model.get_absolute_url()` method. The old definition
    
  1347.   returned  ``"/users/%s/" % urlquote(self.username)`` which was arbitrary
    
  1348.   since applications may or may not define such a url in ``urlpatterns``.
    
  1349.   Define a ``get_absolute_url()`` method on your own custom user object or use
    
  1350.   :setting:`ABSOLUTE_URL_OVERRIDES` if you want a URL for your user.
    
  1351. 
    
  1352. * The static asset-serving functionality of the
    
  1353.   :class:`django.test.LiveServerTestCase` class has been simplified: Now it's
    
  1354.   only able to serve content already present in :setting:`STATIC_ROOT` when
    
  1355.   tests are run. The ability to transparently serve all the static assets
    
  1356.   (similarly to what one gets with :setting:`DEBUG = True <DEBUG>` at
    
  1357.   development-time) has been moved to a new class that lives in the
    
  1358.   ``staticfiles`` application (the one actually in charge of such feature):
    
  1359.   :class:`django.contrib.staticfiles.testing.StaticLiveServerTestCase`. In other
    
  1360.   words, ``LiveServerTestCase`` itself is less powerful but at the same time
    
  1361.   has less magic.
    
  1362. 
    
  1363.   Rationale behind this is removal of dependency of non-contrib code on
    
  1364.   contrib applications.
    
  1365. 
    
  1366. * The old cache URI syntax (e.g. ``"locmem://"``) is no longer supported. It
    
  1367.   still worked, even though it was not documented or officially supported. If
    
  1368.   you're still using it, please update to the current :setting:`CACHES` syntax.
    
  1369. 
    
  1370. * The default ordering of ``Form`` fields in case of inheritance has changed to
    
  1371.   follow normal Python MRO. Fields are now discovered by iterating through the
    
  1372.   MRO in reverse with the topmost class coming last. This only affects you if
    
  1373.   you relied on the default field ordering while having fields defined on both
    
  1374.   the current class *and* on a parent ``Form``.
    
  1375. 
    
  1376. * The ``required`` argument of
    
  1377.   :class:`~django.forms.SelectDateWidget` has been removed.
    
  1378.   This widget now respects the form field's ``is_required`` attribute like
    
  1379.   other widgets.
    
  1380. 
    
  1381. * ``Widget.is_hidden`` is now a read-only property, getting its value by
    
  1382.   introspecting the presence of ``input_type == 'hidden'``.
    
  1383. 
    
  1384. * :meth:`~django.db.models.query.QuerySet.select_related` now chains in the
    
  1385.   same way as other similar calls like ``prefetch_related``. That is,
    
  1386.   ``select_related('foo', 'bar')`` is equivalent to
    
  1387.   ``select_related('foo').select_related('bar')``. Previously the latter would
    
  1388.   have been equivalent to ``select_related('bar')``.
    
  1389. 
    
  1390. * GeoDjango dropped support for GEOS < 3.1.
    
  1391. 
    
  1392. * The ``init_connection_state`` method of database backends now executes in
    
  1393.   autocommit mode (unless you set :setting:`AUTOCOMMIT <DATABASE-AUTOCOMMIT>`
    
  1394.   to ``False``). If you maintain a custom database backend, you should check
    
  1395.   that method.
    
  1396. 
    
  1397. * The ``django.db.backends.BaseDatabaseFeatures.allows_primary_key_0``
    
  1398.   attribute has been renamed to ``allows_auto_pk_0`` to better describe it.
    
  1399.   It's ``True`` for all database backends included with Django except MySQL
    
  1400.   which does allow primary keys with value 0. It only forbids *autoincrement*
    
  1401.   primary keys with value 0.
    
  1402. 
    
  1403. * Shadowing model fields defined in a parent model has been forbidden as this
    
  1404.   creates ambiguity in the expected model behavior. In addition, clashing
    
  1405.   fields in the model inheritance hierarchy result in a system check error.
    
  1406.   For example, if you use multi-inheritance, you need to define custom primary
    
  1407.   key fields on parent models, otherwise the default ``id`` fields will clash.
    
  1408.   See :ref:`model-multiple-inheritance-topic` for details.
    
  1409. 
    
  1410. * ``django.utils.translation.parse_accept_lang_header()`` now returns
    
  1411.   lowercase locales, instead of the case as it was provided. As locales should
    
  1412.   be treated case-insensitive this allows us to speed up locale detection.
    
  1413. 
    
  1414. * ``django.utils.translation.get_language_from_path()`` and
    
  1415.   ``django.utils.translation.trans_real.get_supported_language_variant()``
    
  1416.   now no longer have a ``supported`` argument.
    
  1417. 
    
  1418. * The ``shortcut`` view in ``django.contrib.contenttypes.views`` now supports
    
  1419.   protocol-relative URLs (e.g. ``//example.com``).
    
  1420. 
    
  1421. * :class:`~django.contrib.contenttypes.fields.GenericRelation` now supports an
    
  1422.   optional ``related_query_name`` argument. Setting ``related_query_name`` adds
    
  1423.   a relation from the related object back to the content type for filtering,
    
  1424.   ordering and other query operations.
    
  1425. 
    
  1426. * When running tests on PostgreSQL, the :setting:`USER` will need read access
    
  1427.   to the built-in ``postgres`` database. This is in lieu of the previous
    
  1428.   behavior of connecting to the actual non-test database.
    
  1429. 
    
  1430. * As part of the :doc:`System check framework </ref/checks>`, :ref:`fields,
    
  1431.   models, and model managers <field-checking>` all implement a ``check()``
    
  1432.   method that is registered with the check framework. If you have an existing
    
  1433.   method called ``check()`` on one of these objects, you will need to rename it.
    
  1434. 
    
  1435. * As noted above in the "Cache" section of "Minor Features", defining the
    
  1436.   :setting:`TIMEOUT <CACHES-TIMEOUT>` argument of the
    
  1437.   :setting:`CACHES` setting as ``None`` will set the cache keys as
    
  1438.   "non-expiring". Previously, with the memcache backend, a
    
  1439.   :setting:`TIMEOUT <CACHES-TIMEOUT>` of ``0`` would set non-expiring keys,
    
  1440.   but this was inconsistent with the set-and-expire (i.e. no caching) behavior
    
  1441.   of ``set("key", "value", timeout=0)``. If you want non-expiring keys,
    
  1442.   please update your settings to use ``None`` instead of ``0`` as the latter
    
  1443.   now designates set-and-expire in the settings as well.
    
  1444. 
    
  1445. * The ``sql*`` management commands now respect the ``allow_migrate()`` method
    
  1446.   of :setting:`DATABASE_ROUTERS`. If you have models synced to non-default
    
  1447.   databases, use the ``--database`` flag to get SQL for those models
    
  1448.   (previously they would always be included in the output).
    
  1449. 
    
  1450. * Decoding the query string from URLs now falls back to the ISO-8859-1 encoding
    
  1451.   when the input is not valid UTF-8.
    
  1452. 
    
  1453. * With the addition of the
    
  1454.   ``django.contrib.auth.middleware.SessionAuthenticationMiddleware`` to
    
  1455.   the default project template (pre-1.7.2 only), a database must be created
    
  1456.   before accessing a page using :djadmin:`runserver`.
    
  1457. 
    
  1458. * The addition of the ``schemes`` argument to ``URLValidator`` will appear
    
  1459.   as a backwards-incompatible change if you were previously using a custom
    
  1460.   regular expression to validate schemes. Any scheme not listed in ``schemes``
    
  1461.   will fail validation, even if the regular expression matches the given URL.
    
  1462. 
    
  1463. .. _deprecated-features-1.7:
    
  1464. 
    
  1465. Features deprecated in 1.7
    
  1466. ==========================
    
  1467. 
    
  1468. ``django.core.cache.get_cache``
    
  1469. -------------------------------
    
  1470. 
    
  1471. ``django.core.cache.get_cache`` has been supplanted by
    
  1472. :data:`django.core.cache.caches`.
    
  1473. 
    
  1474. ``django.utils.dictconfig``/``django.utils.importlib``
    
  1475. ------------------------------------------------------
    
  1476. 
    
  1477. ``django.utils.dictconfig`` and ``django.utils.importlib`` were copies of
    
  1478. respectively :mod:`logging.config` and :mod:`importlib` provided for Python
    
  1479. versions prior to 2.7. They have been deprecated.
    
  1480. 
    
  1481. ``django.utils.module_loading.import_by_path``
    
  1482. ----------------------------------------------
    
  1483. 
    
  1484. The current ``django.utils.module_loading.import_by_path`` function
    
  1485. catches ``AttributeError``, ``ImportError``, and ``ValueError`` exceptions,
    
  1486. and re-raises :exc:`~django.core.exceptions.ImproperlyConfigured`. Such
    
  1487. exception masking makes it needlessly hard to diagnose circular import
    
  1488. problems, because it makes it look like the problem comes from inside Django.
    
  1489. It has been deprecated in favor of
    
  1490. :meth:`~django.utils.module_loading.import_string`.
    
  1491. 
    
  1492. ``django.utils.tzinfo``
    
  1493. -----------------------
    
  1494. 
    
  1495. ``django.utils.tzinfo`` provided two :class:`~datetime.tzinfo` subclasses,
    
  1496. ``LocalTimezone`` and ``FixedOffset``. They've been deprecated in favor of
    
  1497. more correct alternatives provided by :mod:`django.utils.timezone`,
    
  1498. :func:`django.utils.timezone.get_default_timezone` and
    
  1499. :func:`django.utils.timezone.get_fixed_timezone`.
    
  1500. 
    
  1501. ``django.utils.unittest``
    
  1502. -------------------------
    
  1503. 
    
  1504. ``django.utils.unittest`` provided uniform access to the ``unittest2`` library
    
  1505. on all Python versions. Since ``unittest2`` became the standard library's
    
  1506. :mod:`unittest` module in Python 2.7, and Django 1.7 drops support for older
    
  1507. Python versions, this module isn't useful anymore. It has been deprecated. Use
    
  1508. :mod:`unittest` instead.
    
  1509. 
    
  1510. ``django.utils.datastructures.SortedDict``
    
  1511. ------------------------------------------
    
  1512. 
    
  1513. As :class:`~collections.OrderedDict` was added to the standard library in
    
  1514. Python 2.7, ``SortedDict`` is no longer needed and has been deprecated.
    
  1515. 
    
  1516. The two additional, deprecated methods provided by ``SortedDict`` (``insert()``
    
  1517. and ``value_for_index()``) have been removed. If you relied on these methods to
    
  1518. alter structures like form fields, you should now treat these ``OrderedDict``\s
    
  1519. as immutable objects and override them to change their content.
    
  1520. 
    
  1521. For example, you might want to override ``MyFormClass.base_fields`` (although
    
  1522. this attribute isn't considered a public API) to change the ordering of fields
    
  1523. for all ``MyFormClass`` instances; or similarly, you could override
    
  1524. ``self.fields`` from inside ``MyFormClass.__init__()``, to change the fields
    
  1525. for a particular form instance. For example (from Django itself)::
    
  1526. 
    
  1527.     PasswordChangeForm.base_fields = OrderedDict(
    
  1528.         (k, PasswordChangeForm.base_fields[k])
    
  1529.         for k in ['old_password', 'new_password1', 'new_password2']
    
  1530.     )
    
  1531. 
    
  1532. Custom SQL location for models package
    
  1533. --------------------------------------
    
  1534. 
    
  1535. Previously, if models were organized in a package (``myapp/models/``) rather
    
  1536. than simply ``myapp/models.py``, Django would look for initial SQL data in
    
  1537. ``myapp/models/sql/``. This bug has been fixed so that Django
    
  1538. will search ``myapp/sql/`` as documented. After this issue was fixed, migrations
    
  1539. were added which deprecates initial SQL data. Thus, while this change still
    
  1540. exists, the deprecation is irrelevant as the entire feature will be removed in
    
  1541. Django 1.9.
    
  1542. 
    
  1543. Reorganization of ``django.contrib.sites``
    
  1544. ------------------------------------------
    
  1545. 
    
  1546. ``django.contrib.sites`` provides reduced functionality when it isn't in
    
  1547. :setting:`INSTALLED_APPS`. The app-loading refactor adds some constraints in
    
  1548. that situation. As a consequence, two objects were moved, and the old
    
  1549. locations are deprecated:
    
  1550. 
    
  1551. * :class:`~django.contrib.sites.requests.RequestSite` now lives in
    
  1552.   ``django.contrib.sites.requests``.
    
  1553. * :func:`~django.contrib.sites.shortcuts.get_current_site` now lives in
    
  1554.   ``django.contrib.sites.shortcuts``.
    
  1555. 
    
  1556. ``declared_fieldsets`` attribute on ``ModelAdmin``
    
  1557. --------------------------------------------------
    
  1558. 
    
  1559. ``ModelAdmin.declared_fieldsets`` has been deprecated. Despite being a private
    
  1560. API, it will go through a regular deprecation path. This attribute was mostly
    
  1561. used by methods that bypassed ``ModelAdmin.get_fieldsets()`` but this was
    
  1562. considered a bug and has been addressed.
    
  1563. 
    
  1564. Reorganization of ``django.contrib.contenttypes``
    
  1565. -------------------------------------------------
    
  1566. 
    
  1567. Since ``django.contrib.contenttypes.generic`` defined both admin and model
    
  1568. related objects, an import of this module could trigger unexpected side effects.
    
  1569. As a consequence, its contents were split into :mod:`~django.contrib.contenttypes`
    
  1570. submodules and the ``django.contrib.contenttypes.generic`` module is deprecated:
    
  1571. 
    
  1572. * :class:`~django.contrib.contenttypes.fields.GenericForeignKey` and
    
  1573.   :class:`~django.contrib.contenttypes.fields.GenericRelation` now live in
    
  1574.   :mod:`~django.contrib.contenttypes.fields`.
    
  1575. * :class:`~django.contrib.contenttypes.forms.BaseGenericInlineFormSet` and
    
  1576.   :func:`~django.contrib.contenttypes.forms.generic_inlineformset_factory` now
    
  1577.   live in :mod:`~django.contrib.contenttypes.forms`.
    
  1578. * :class:`~django.contrib.contenttypes.admin.GenericInlineModelAdmin`,
    
  1579.   :class:`~django.contrib.contenttypes.admin.GenericStackedInline` and
    
  1580.   :class:`~django.contrib.contenttypes.admin.GenericTabularInline` now live in
    
  1581.   :mod:`~django.contrib.contenttypes.admin`.
    
  1582. 
    
  1583. ``syncdb``
    
  1584. ----------
    
  1585. 
    
  1586. The ``syncdb`` command has been deprecated in favor of the new :djadmin:`migrate`
    
  1587. command. ``migrate`` takes the same arguments as ``syncdb`` used to plus a few
    
  1588. more, so it's safe to just change the name you're calling and nothing else.
    
  1589. 
    
  1590. ``util`` modules renamed to ``utils``
    
  1591. -------------------------------------
    
  1592. 
    
  1593. The following instances of ``util.py`` in the Django codebase have been renamed
    
  1594. to ``utils.py`` in an effort to unify all util and utils references:
    
  1595. 
    
  1596. * ``django.contrib.admin.util``
    
  1597. * ``django.contrib.gis.db.backends.util``
    
  1598. * ``django.db.backends.util``
    
  1599. * ``django.forms.util``
    
  1600. 
    
  1601. ``get_formsets`` method on ``ModelAdmin``
    
  1602. -----------------------------------------
    
  1603. 
    
  1604. ``ModelAdmin.get_formsets`` has been deprecated in favor of the new
    
  1605. :meth:`~django.contrib.admin.ModelAdmin.get_formsets_with_inlines`, in order to
    
  1606. better handle the case of selectively showing inlines on a ``ModelAdmin``.
    
  1607. 
    
  1608. ``IPAddressField``
    
  1609. ------------------
    
  1610. 
    
  1611. The ``django.db.models.IPAddressField`` and ``django.forms.IPAddressField``
    
  1612. fields have been deprecated in favor of
    
  1613. :class:`django.db.models.GenericIPAddressField` and
    
  1614. :class:`django.forms.GenericIPAddressField`.
    
  1615. 
    
  1616. ``BaseMemcachedCache._get_memcache_timeout`` method
    
  1617. ---------------------------------------------------
    
  1618. 
    
  1619. The ``BaseMemcachedCache._get_memcache_timeout()`` method has been renamed to
    
  1620. ``get_backend_timeout()``. Despite being a private API, it will go through the
    
  1621. normal deprecation.
    
  1622. 
    
  1623. Natural key serialization options
    
  1624. ---------------------------------
    
  1625. 
    
  1626. The ``--natural`` and ``-n`` options for :djadmin:`dumpdata` have been
    
  1627. deprecated. Use :option:`dumpdata --natural-foreign` instead.
    
  1628. 
    
  1629. Similarly, the ``use_natural_keys`` argument for ``serializers.serialize()``
    
  1630. has been deprecated. Use ``use_natural_foreign_keys`` instead.
    
  1631. 
    
  1632. Merging of ``POST`` and ``GET`` arguments into ``WSGIRequest.REQUEST``
    
  1633. ----------------------------------------------------------------------
    
  1634. 
    
  1635. It was already strongly suggested that you use ``GET`` and ``POST`` instead of
    
  1636. ``REQUEST``, because the former are more explicit. The property ``REQUEST`` is
    
  1637. deprecated and will be removed in Django 1.9.
    
  1638. 
    
  1639. ``django.utils.datastructures.MergeDict`` class
    
  1640. -----------------------------------------------
    
  1641. 
    
  1642. ``MergeDict`` exists primarily to support merging ``POST`` and ``GET``
    
  1643. arguments into a ``REQUEST`` property on ``WSGIRequest``. To merge
    
  1644. dictionaries, use ``dict.update()`` instead. The class ``MergeDict`` is
    
  1645. deprecated and will be removed in Django 1.9.
    
  1646. 
    
  1647. Language codes ``zh-cn``, ``zh-tw`` and ``fy-nl``
    
  1648. -------------------------------------------------
    
  1649. 
    
  1650. The currently used language codes for Simplified Chinese ``zh-cn``,
    
  1651. Traditional Chinese ``zh-tw`` and (Western) Frysian ``fy-nl`` are deprecated
    
  1652. and should be replaced by the language codes ``zh-hans``, ``zh-hant`` and
    
  1653. ``fy`` respectively. If you use these language codes, you should rename the
    
  1654. locale directories and update your settings to reflect these changes. The
    
  1655. deprecated language codes will be removed in Django 1.9.
    
  1656. 
    
  1657. ``django.utils.functional.memoize`` function
    
  1658. --------------------------------------------
    
  1659. 
    
  1660. The function ``memoize`` is deprecated and should be replaced by the
    
  1661. ``functools.lru_cache`` decorator (available from Python 3.2 onward).
    
  1662. 
    
  1663. Django ships a backport of this decorator for older Python versions and it's
    
  1664. available at ``django.utils.lru_cache.lru_cache``. The deprecated function will
    
  1665. be removed in Django 1.9.
    
  1666. 
    
  1667. Geo Sitemaps
    
  1668. ------------
    
  1669. 
    
  1670. Google has retired support for the Geo Sitemaps format. Hence Django support
    
  1671. for Geo Sitemaps is deprecated and will be removed in Django 1.8.
    
  1672. 
    
  1673. Passing callable arguments to queryset methods
    
  1674. ----------------------------------------------
    
  1675. 
    
  1676. Callable arguments for querysets were an undocumented feature that was
    
  1677. unreliable. It's been deprecated and will be removed in Django 1.9.
    
  1678. 
    
  1679. Callable arguments were evaluated when a queryset was constructed rather than
    
  1680. when it was evaluated, thus this feature didn't offer any benefit compared to
    
  1681. evaluating arguments before passing them to queryset and created confusion that
    
  1682. the arguments may have been evaluated at query time.
    
  1683. 
    
  1684. ``ADMIN_FOR`` setting
    
  1685. ---------------------
    
  1686. 
    
  1687. The ``ADMIN_FOR`` feature, part of the admindocs, has been removed. You can
    
  1688. remove the setting from your configuration at your convenience.
    
  1689. 
    
  1690. ``SplitDateTimeWidget`` with ``DateTimeField``
    
  1691. ----------------------------------------------
    
  1692. 
    
  1693. ``SplitDateTimeWidget`` support in :class:`~django.forms.DateTimeField` is
    
  1694. deprecated, use ``SplitDateTimeWidget`` with
    
  1695. :class:`~django.forms.SplitDateTimeField` instead.
    
  1696. 
    
  1697. ``validate``
    
  1698. ------------
    
  1699. 
    
  1700. The ``validate`` management command is deprecated in favor of the
    
  1701. :djadmin:`check` command.
    
  1702. 
    
  1703. ``django.core.management.BaseCommand``
    
  1704. --------------------------------------
    
  1705. 
    
  1706. ``requires_model_validation`` is deprecated in favor of a new
    
  1707. ``requires_system_checks`` flag. If the latter flag is missing, then the
    
  1708. value of the former flag is used. Defining both ``requires_system_checks`` and
    
  1709. ``requires_model_validation`` results in an error.
    
  1710. 
    
  1711. The ``check()`` method has replaced the old ``validate()`` method.
    
  1712. 
    
  1713. ``ModelAdmin`` validators
    
  1714. -------------------------
    
  1715. 
    
  1716. The ``ModelAdmin.validator_class`` and ``default_validator_class`` attributes
    
  1717. are deprecated in favor of the new ``checks_class`` attribute.
    
  1718. 
    
  1719. The ``ModelAdmin.validate()`` method is deprecated in favor of
    
  1720. ``ModelAdmin.check()``.
    
  1721. 
    
  1722. The ``django.contrib.admin.validation`` module is deprecated.
    
  1723. 
    
  1724. ``django.db.backends.DatabaseValidation.validate_field``
    
  1725. --------------------------------------------------------
    
  1726. 
    
  1727. This method is deprecated in favor of a new ``check_field`` method.
    
  1728. The functionality required by ``check_field()`` is the same as that provided
    
  1729. by ``validate_field()``, but the output format is different. Third-party database
    
  1730. backends needing this functionality should provide an implementation of
    
  1731. ``check_field()``.
    
  1732. 
    
  1733. Loading ``ssi`` and ``url`` template tags from ``future`` library
    
  1734. -----------------------------------------------------------------
    
  1735. 
    
  1736. Django 1.3 introduced ``{% load ssi from future %}`` and
    
  1737. ``{% load url from future %}`` syntax for forward compatibility of the
    
  1738. ``ssi`` and :ttag:`url` template tags. This syntax is now deprecated and
    
  1739. will be removed in Django 1.9. You can simply remove the
    
  1740. ``{% load ... from future %}`` tags.
    
  1741. 
    
  1742. ``django.utils.text.javascript_quote``
    
  1743. --------------------------------------
    
  1744. 
    
  1745. ``javascript_quote()`` was an undocumented function present in ``django.utils.text``.
    
  1746. It was used internally in the ``javascript_catalog()`` view
    
  1747. whose implementation was changed to make use of ``json.dumps()`` instead.
    
  1748. If you were relying on this function to provide safe output from untrusted
    
  1749. strings, you should use ``django.utils.html.escapejs`` or the
    
  1750. :tfilter:`escapejs` template filter.
    
  1751. If all you need is to generate valid JavaScript strings, you can simply use
    
  1752. ``json.dumps()``.
    
  1753. 
    
  1754. ``fix_ampersands`` utils method and template filter
    
  1755. ---------------------------------------------------
    
  1756. 
    
  1757. The ``django.utils.html.fix_ampersands`` method and the ``fix_ampersands``
    
  1758. template filter are deprecated, as the escaping of ampersands is already taken care
    
  1759. of by Django's standard HTML escaping features. Combining this with ``fix_ampersands``
    
  1760. would either result in double escaping, or, if the output is assumed to be safe,
    
  1761. a risk of introducing XSS vulnerabilities. Along with ``fix_ampersands``,
    
  1762. ``django.utils.html.clean_html`` is deprecated, an undocumented function that calls
    
  1763. ``fix_ampersands``.
    
  1764. As this is an accelerated deprecation, ``fix_ampersands`` and ``clean_html``
    
  1765. will be removed in Django 1.8.
    
  1766. 
    
  1767. Reorganization of database test settings
    
  1768. ----------------------------------------
    
  1769. 
    
  1770. All database settings with a ``TEST_`` prefix have been deprecated in favor of
    
  1771. entries in a :setting:`TEST <DATABASE-TEST>` dictionary in the database
    
  1772. settings. The old settings will be supported until Django 1.9. For backwards
    
  1773. compatibility with older versions of Django, you can define both versions of
    
  1774. the settings as long as they match.
    
  1775. 
    
  1776. FastCGI support
    
  1777. ---------------
    
  1778. 
    
  1779. FastCGI support via the ``runfcgi`` management command will be removed in
    
  1780. Django 1.9. Please deploy your project using WSGI.
    
  1781. 
    
  1782. Moved objects in ``contrib.sites``
    
  1783. ----------------------------------
    
  1784. 
    
  1785. Following the app-loading refactor, two objects in
    
  1786. ``django.contrib.sites.models`` needed to be moved because they must be
    
  1787. available without importing ``django.contrib.sites.models`` when
    
  1788. ``django.contrib.sites`` isn't installed. Import ``RequestSite`` from
    
  1789. ``django.contrib.sites.requests`` and ``get_current_site()`` from
    
  1790. ``django.contrib.sites.shortcuts``. The old import locations will work until
    
  1791. Django 1.9.
    
  1792. 
    
  1793. ``django.forms.forms.get_declared_fields()``
    
  1794. --------------------------------------------
    
  1795. 
    
  1796. Django no longer uses this functional internally. Even though it's a private
    
  1797. API, it'll go through the normal deprecation cycle.
    
  1798. 
    
  1799. Private Query Lookup APIs
    
  1800. -------------------------
    
  1801. 
    
  1802. Private APIs ``django.db.models.sql.where.WhereNode.make_atom()`` and
    
  1803. ``django.db.models.sql.where.Constraint`` are deprecated in favor of the new
    
  1804. :doc:`custom lookups API </ref/models/lookups>`.
    
  1805. 
    
  1806. .. _removed-features-1.7:
    
  1807. 
    
  1808. Features removed in 1.7
    
  1809. =======================
    
  1810. 
    
  1811. These features have reached the end of their deprecation cycle and are removed
    
  1812. in Django 1.7. See :ref:`deprecated-features-1.5` for details, including how to
    
  1813. remove usage of these features.
    
  1814. 
    
  1815. * ``django.utils.simplejson`` is removed.
    
  1816. 
    
  1817. * ``django.utils.itercompat.product`` is removed.
    
  1818. 
    
  1819. * INSTALLED_APPS and TEMPLATE_DIRS are no longer corrected from a plain
    
  1820.   string into a tuple.
    
  1821. 
    
  1822. * :class:`~django.http.HttpResponse`,
    
  1823.   :class:`~django.template.response.SimpleTemplateResponse`,
    
  1824.   :class:`~django.template.response.TemplateResponse`,
    
  1825.   ``render_to_response()``, :func:`~django.contrib.sitemaps.views.index`, and
    
  1826.   :func:`~django.contrib.sitemaps.views.sitemap` no longer take a ``mimetype``
    
  1827.   argument
    
  1828. 
    
  1829. * :class:`~django.http.HttpResponse` immediately consumes its content if it's
    
  1830.   an iterator.
    
  1831. 
    
  1832. * The ``AUTH_PROFILE_MODULE`` setting, and the ``get_profile()`` method on
    
  1833.   the User model are removed.
    
  1834. 
    
  1835. * The ``cleanup`` management command is removed.
    
  1836. 
    
  1837. * The ``daily_cleanup.py`` script is removed.
    
  1838. 
    
  1839. * :meth:`~django.db.models.query.QuerySet.select_related` no longer has a
    
  1840.   ``depth`` keyword argument.
    
  1841. 
    
  1842. * The ``get_warnings_state()``/``restore_warnings_state()``
    
  1843.   functions from :mod:`django.test.utils` and the ``save_warnings_state()``/
    
  1844.   ``restore_warnings_state()``
    
  1845.   :ref:`django.test.*TestCase <django-testcase-subclasses>` are removed.
    
  1846. 
    
  1847. * The ``check_for_test_cookie`` method in
    
  1848.   :class:`~django.contrib.auth.forms.AuthenticationForm` is removed.
    
  1849. 
    
  1850. * The version of ``django.contrib.auth.views.password_reset_confirm()`` that
    
  1851.   supports base36 encoded user IDs
    
  1852.   (``django.contrib.auth.views.password_reset_confirm_uidb36``) is removed.
    
  1853. 
    
  1854. * The ``django.utils.encoding.StrAndUnicode`` mix-in is removed.