2013-07-01 13:53:06 +02:00
|
|
|
|
============================================
|
|
|
|
|
Django 1.7 release notes - UNDER DEVELOPMENT
|
|
|
|
|
============================================
|
|
|
|
|
|
|
|
|
|
Welcome to Django 1.7!
|
|
|
|
|
|
|
|
|
|
These release notes cover the `new features`_, as well as some `backwards
|
|
|
|
|
incompatible changes`_ you'll want to be aware of when upgrading from Django
|
|
|
|
|
1.6 or older versions. We've also dropped some features, which are detailed in
|
|
|
|
|
:doc:`our deprecation plan </internals/deprecation>`, and we've `begun the
|
|
|
|
|
deprecation process for some features`_.
|
|
|
|
|
|
|
|
|
|
.. _`new features`: `What's new in Django 1.7`_
|
|
|
|
|
.. _`backwards incompatible changes`: `Backwards incompatible changes in 1.7`_
|
|
|
|
|
.. _`begun the deprecation process for some features`: `Features deprecated in 1.7`_
|
|
|
|
|
|
2013-07-13 19:29:11 +02:00
|
|
|
|
Python compatibility
|
|
|
|
|
====================
|
|
|
|
|
|
|
|
|
|
Django 1.7 requires Python 2.7 or above, though we **highly recommend**
|
|
|
|
|
the latest minor release. Support for Python 2.6 has been dropped.
|
|
|
|
|
|
|
|
|
|
This change should affect only a small number of Django users, as most
|
|
|
|
|
operating-system vendors today are shipping Python 2.7 or newer as their default
|
|
|
|
|
version. If you're still using Python 2.6, however, you'll need to stick to
|
|
|
|
|
Django 1.6 until you can upgrade your Python version. Per :doc:`our support
|
|
|
|
|
policy </internals/release-process>`, Django 1.6 will continue to receive
|
|
|
|
|
security support until the release of Django 1.8.
|
|
|
|
|
|
2013-07-01 13:53:06 +02:00
|
|
|
|
What's new in Django 1.7
|
|
|
|
|
========================
|
|
|
|
|
|
2013-07-30 12:52:36 +02:00
|
|
|
|
Schema migrations
|
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2013-08-10 21:00:12 +02:00
|
|
|
|
Django now has built-in support for schema migrations. It allows models
|
|
|
|
|
to be updated, changed, and deleted by creating migration files that represent
|
|
|
|
|
the model changes and which can be run on any development, staging or production
|
|
|
|
|
database.
|
2013-07-30 12:52:36 +02:00
|
|
|
|
|
|
|
|
|
Migrations are covered in :doc:`their own documentation</topics/migrations>`,
|
|
|
|
|
but a few of the key features are:
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
* ``syncdb`` has been deprecated and replaced by ``migrate``. Don't worry -
|
2013-08-10 21:00:12 +02:00
|
|
|
|
calls to ``syncdb`` will still work as before.
|
2013-07-30 12:52:36 +02:00
|
|
|
|
|
|
|
|
|
* A new ``makemigrations`` command provides an easy way to autodetect changes
|
|
|
|
|
to your models and make migrations for them.
|
|
|
|
|
|
2013-09-10 01:02:41 +02:00
|
|
|
|
* :data:`~django.db.models.signals.pre_syncdb` and
|
2013-07-30 12:52:36 +02:00
|
|
|
|
:data:`~django.db.models.signals.post_syncdb` have been renamed to
|
|
|
|
|
:data:`~django.db.models.signals.pre_migrate` and
|
|
|
|
|
:data:`~django.db.models.signals.post_migrate` respectively. The
|
|
|
|
|
``create_models``/``created_models`` argument has also been deprecated.
|
|
|
|
|
|
2013-07-30 13:08:59 +02:00
|
|
|
|
* The ``allow_syncdb`` method on database routers is now called ``allow_migrate``,
|
|
|
|
|
but still performs the same function. Routers with ``allow_syncdb`` methods
|
|
|
|
|
will still work, but that method name is deprecated and you should change
|
|
|
|
|
it as soon as possible (nothing more than renaming is required).
|
2013-07-30 12:52:36 +02:00
|
|
|
|
|
2013-08-09 15:31:24 +02:00
|
|
|
|
New method on Field subclasses
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2013-08-10 21:00:12 +02:00
|
|
|
|
To help power both schema migrations and composite keys, the :class:`~django.db.models.Field` API now
|
2013-08-09 15:31:24 +02:00
|
|
|
|
has a new required method: ``deconstruct()``.
|
|
|
|
|
|
|
|
|
|
This method takes no arguments, and returns a tuple of four items:
|
|
|
|
|
|
|
|
|
|
* ``name``: The field's attribute name on its parent model, or None if it is not part of a model
|
|
|
|
|
* ``path``: A dotted, Python path to the class of this field, including the class name.
|
|
|
|
|
* ``args``: Positional arguments, as a list
|
|
|
|
|
* ``kwargs``: Keyword arguments, as a dict
|
|
|
|
|
|
|
|
|
|
These four values allow any field to be serialized into a file, as well as
|
|
|
|
|
allowing the field to be copied safely, both essential parts of these new features.
|
|
|
|
|
|
|
|
|
|
This change should not affect you unless you write custom Field subclasses;
|
|
|
|
|
if you do, you may need to reimplement the ``deconstruct()`` method if your
|
|
|
|
|
subclass changes the method signature of ``__init__`` in any way. If your
|
|
|
|
|
field just inherits from a built-in Django field and doesn't override ``__init__``,
|
|
|
|
|
no changes are necessary.
|
|
|
|
|
|
|
|
|
|
If you do need to override ``deconstruct()``, a good place to start is the
|
|
|
|
|
built-in Django fields (``django/db/models/fields/__init__.py``) as several
|
|
|
|
|
fields, including ``DecimalField`` and ``DateField``, override it and show how
|
|
|
|
|
to call the method on the superclass and simply add or remove extra arguments.
|
|
|
|
|
|
2013-07-26 10:59:40 +02:00
|
|
|
|
Calling custom ``QuerySet`` methods from the ``Manager``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The :meth:`QuerySet.as_manager() <django.db.models.query.QuerySet.as_manager>`
|
|
|
|
|
class method has been added to :ref:`create Manager with QuerySet methods
|
|
|
|
|
<create-manager-with-queryset-methods>`.
|
|
|
|
|
|
2013-09-18 19:31:07 +02:00
|
|
|
|
Using a custom manager when traversing reverse relations
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
It is now possible to :ref:`specify a custom manager
|
|
|
|
|
<using-custom-reverse-manager>` when traversing a reverse relationship.
|
|
|
|
|
|
2013-11-06 18:25:05 +01:00
|
|
|
|
New ``Prefetch`` object for advanced ``prefetch_related`` operations.
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The new :class:`~django.db.models.Prefetch` object allows customizing
|
|
|
|
|
prefetch operations.
|
|
|
|
|
|
|
|
|
|
You can specify the ``QuerySet`` used to traverse a given relation
|
|
|
|
|
or customize the storage location of prefetch results.
|
|
|
|
|
|
|
|
|
|
This enables things like filtering prefetched relations, calling
|
|
|
|
|
:meth:`~django.db.models.query.QuerySet.select_related()` from a prefetched
|
|
|
|
|
relation, or prefetching the same relation multiple times with different
|
|
|
|
|
querysets. See :meth:`~django.db.models.query.QuerySet.prefetch_related()`
|
|
|
|
|
for more details.
|
|
|
|
|
|
2013-07-01 16:48:14 +02:00
|
|
|
|
Admin shortcuts support time zones
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The "today" and "now" shortcuts next to date and time input widgets in the
|
|
|
|
|
admin are now operating in the :ref:`current time zone
|
|
|
|
|
<default-current-time-zone>`. Previously, they used the browser time zone,
|
|
|
|
|
which could result in saving the wrong value when it didn't match the current
|
|
|
|
|
time zone on the server.
|
|
|
|
|
|
|
|
|
|
In addition, the widgets now display a help message when the browser and
|
|
|
|
|
server time zone are different, to clarify how the value inserted in the field
|
|
|
|
|
will be interpreted.
|
|
|
|
|
|
2013-09-24 02:17:59 +02:00
|
|
|
|
Using database cursors as context managers
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
Prior to Python 2.7, database cursors could be used as a context manager. The
|
|
|
|
|
specific backend's cursor defined the behavior of the context manager. The
|
|
|
|
|
behavior of magic method lookups was changed with Python 2.7 and cursors were
|
|
|
|
|
no longer usable as context managers.
|
|
|
|
|
|
|
|
|
|
Django 1.7 allows a cursor to be used as a context manager that is a shortcut
|
|
|
|
|
for the following, instead of backend specific behavior.
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
|
|
|
|
|
|
c = connection.cursor()
|
|
|
|
|
try:
|
|
|
|
|
c.execute(...)
|
|
|
|
|
finally:
|
|
|
|
|
c.close()
|
|
|
|
|
|
2013-04-19 19:20:23 +02:00
|
|
|
|
Minor features
|
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
:mod:`django.contrib.admin`
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2013-07-17 21:20:20 +02:00
|
|
|
|
|
2013-09-06 22:15:35 +02:00
|
|
|
|
* You can now implement :attr:`~django.contrib.admin.AdminSite.site_header`,
|
|
|
|
|
:attr:`~django.contrib.admin.AdminSite.site_title`, and
|
|
|
|
|
:attr:`~django.contrib.admin.AdminSite.index_title` attributes on a custom
|
|
|
|
|
:class:`~django.contrib.admin.AdminSite` in order to easily change the admin
|
2013-09-06 21:27:40 +02:00
|
|
|
|
site's page title and header text. No more needing to override templates!
|
|
|
|
|
|
2013-02-25 07:18:27 +01:00
|
|
|
|
* Buttons in :mod:`django.contrib.admin` now use the ``border-radius`` CSS
|
|
|
|
|
property for rounded corners rather than GIF background images.
|
|
|
|
|
|
2013-07-28 04:52:59 +02:00
|
|
|
|
* Some admin templates now have ``app-<app_name>`` and ``model-<model_name>``
|
|
|
|
|
classes in their ``<body>`` tag to allow customizing the CSS per app or per
|
|
|
|
|
model.
|
|
|
|
|
|
2013-07-28 04:50:02 +02:00
|
|
|
|
* The admin changelist cells now have a ``field-<field_name>`` class in the
|
|
|
|
|
HTML to enable style customizations.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
* The admin's search fields can now be customized per-request thanks to the new
|
|
|
|
|
:meth:`django.contrib.admin.ModelAdmin.get_search_fields` method.
|
2013-07-28 17:11:04 +02:00
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
* The :meth:`ModelAdmin.get_fields()
|
|
|
|
|
<django.contrib.admin.ModelAdmin.get_fields>` method may be overridden to
|
|
|
|
|
customize the value of :attr:`ModelAdmin.fields
|
|
|
|
|
<django.contrib.admin.ModelAdmin.fields>`.
|
|
|
|
|
|
2012-12-18 01:04:10 +01:00
|
|
|
|
* In addition to the existing ``admin.site.register`` syntax, you can use the
|
|
|
|
|
new :func:`~django.contrib.admin.register` decorator to register a
|
|
|
|
|
:class:`~django.contrib.admin.ModelAdmin`.
|
|
|
|
|
|
2013-09-06 20:25:13 +02:00
|
|
|
|
* You may specify :meth:`ModelAdmin.list_display_links
|
|
|
|
|
<django.contrib.admin.ModelAdmin.list_display_links>` ``= None`` to disable
|
|
|
|
|
links on the change list page grid.
|
|
|
|
|
|
2013-10-24 17:28:09 +02:00
|
|
|
|
* You may now specify :attr:`ModelAdmin.view_on_site
|
|
|
|
|
<django.contrib.admin.ModelAdmin.view_on_site>` to control whether or not to
|
|
|
|
|
display the "View on site" link.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
:mod:`django.contrib.auth`
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* Any ``**kwargs`` passed to
|
|
|
|
|
:meth:`~django.contrib.auth.models.User.email_user()` are passed to the
|
|
|
|
|
underlying :meth:`~django.core.mail.send_mail()` call.
|
|
|
|
|
|
|
|
|
|
* The :func:`~django.contrib.auth.decorators.permission_required` decorator can
|
|
|
|
|
take a list of permissions as well as a single permission.
|
|
|
|
|
|
|
|
|
|
* You can override the new :meth:`AuthenticationForm.confirm_login_allowed()
|
|
|
|
|
<django.contrib.auth.forms.AuthenticationForm.confirm_login_allowed>` method
|
|
|
|
|
to more easily customize the login policy.
|
|
|
|
|
|
|
|
|
|
* :func:`django.contrib.auth.views.password_reset` takes an optional
|
|
|
|
|
``html_email_template_name`` parameter used to send a multipart HTML email
|
|
|
|
|
for password resets.
|
|
|
|
|
|
2013-10-12 18:07:24 +02:00
|
|
|
|
:mod:`django.contrib.gis`
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The default OpenLayers library version included in widgets has been updated
|
|
|
|
|
from 2.11 to 2.13.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
:mod:`django.contrib.messages`
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The backends for :mod:`django.contrib.messages` that use cookies, will now
|
|
|
|
|
follow the :setting:`SESSION_COOKIE_SECURE` and
|
|
|
|
|
:setting:`SESSION_COOKIE_HTTPONLY` settings.
|
|
|
|
|
|
2013-10-28 21:52:11 +01:00
|
|
|
|
* The :ref:`messages context processor <message-displaying>` now adds a
|
|
|
|
|
dictionary of default levels under the name ``DEFAULT_MESSAGE_LEVELS``.
|
|
|
|
|
|
2013-11-07 16:50:51 +01:00
|
|
|
|
* :class:`~django.contrib.messages.storage.base.Message` objects now have a
|
|
|
|
|
``level_tag`` attribute that contains the string representation of the
|
|
|
|
|
message level.
|
|
|
|
|
|
2013-05-20 21:22:38 +02:00
|
|
|
|
:mod:`django.contrib.redirects`
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* :class:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware`
|
|
|
|
|
has two new attributes
|
|
|
|
|
(:attr:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_gone_class`
|
|
|
|
|
and
|
|
|
|
|
:attr:`~django.contrib.redirects.middleware.RedirectFallbackMiddleware.response_redirect_class`)
|
|
|
|
|
that specify the types of :class:`~django.http.HttpResponse` instances the
|
|
|
|
|
middleware returns.
|
|
|
|
|
|
2013-08-30 06:03:23 +02:00
|
|
|
|
:mod:`django.contrib.sessions`
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The ``"django.contrib.sessions.backends.cached_db"`` session backend now
|
|
|
|
|
respects :setting:`SESSION_CACHE_ALIAS`. In previous versions, it always used
|
|
|
|
|
the `default` cache.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
:mod:`django.contrib.sitemaps`
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2013-02-23 16:28:45 +01:00
|
|
|
|
|
2013-07-23 16:25:21 +02:00
|
|
|
|
* The :mod:`sitemap framework<django.contrib.sitemaps>` now makes use of
|
|
|
|
|
:attr:`~django.contrib.sitemaps.Sitemap.lastmod` to set a ``Last-Modified``
|
|
|
|
|
header in the response. This makes it possible for the
|
|
|
|
|
:class:`~django.middleware.http.ConditionalGetMiddleware` to handle
|
|
|
|
|
conditional ``GET`` requests for sitemaps which set ``lastmod``.
|
|
|
|
|
|
2013-10-19 14:40:12 +02:00
|
|
|
|
:mod:`django.contrib.staticfiles`
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The :ref:`static files storage classes <staticfiles-storages>` may be
|
2013-11-05 11:02:54 +01:00
|
|
|
|
subclassed to override the permissions that collected static files and
|
|
|
|
|
directories receive by setting the
|
2013-10-19 14:40:12 +02:00
|
|
|
|
:attr:`~django.core.files.storage.FileSystemStorage.file_permissions_mode`
|
2013-11-05 11:02:54 +01:00
|
|
|
|
and :attr:`~django.core.files.storage.FileSystemStorage.directory_permissions_mode`
|
|
|
|
|
parameters. See :djadmin:`collectstatic` for example usage.
|
2013-10-19 14:40:12 +02:00
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
:mod:`django.contrib.syndication`
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The :class:`~django.utils.feedgenerator.Atom1Feed` syndication feed's
|
|
|
|
|
``updated`` element now utilizes ``updateddate`` instead of ``pubdate``,
|
|
|
|
|
allowing the ``published`` element to be included in the feed (which
|
|
|
|
|
relies on ``pubdate``).
|
|
|
|
|
|
2013-10-19 00:49:24 +02:00
|
|
|
|
Cache
|
|
|
|
|
^^^^^
|
|
|
|
|
|
|
|
|
|
* Access to caches configured in :setting:`CACHES` is now available via
|
|
|
|
|
:data:`django.core.cache.caches`. This dict-like object provides a different
|
|
|
|
|
instance per thread. It supersedes :func:`django.core.cache.get_cache` which
|
|
|
|
|
is now deprecated.
|
|
|
|
|
|
|
|
|
|
* If you instanciate cache backends directly, be aware that they aren't
|
|
|
|
|
thread-safe any more, as :data:`django.core.cache.caches` now yields
|
|
|
|
|
differend instances per thread.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
Email
|
|
|
|
|
^^^^^
|
|
|
|
|
|
|
|
|
|
* :func:`~django.core.mail.send_mail` now accepts an ``html_message``
|
|
|
|
|
parameter for sending a multipart ``text/plain`` and ``text/html`` email.
|
2013-10-15 17:18:06 +02:00
|
|
|
|
* The SMTP :class:`~django.core.mail.backends.smtp.EmailBackend` now accepts a
|
|
|
|
|
:attr:`~django.core.mail.backends.smtp.EmailBackend.timeout` parameter.
|
2013-08-27 15:39:56 +02:00
|
|
|
|
|
|
|
|
|
File Uploads
|
|
|
|
|
^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The new :attr:`UploadedFile.content_type_extra
|
|
|
|
|
<django.core.files.uploadedfile.UploadedFile.content_type_extra>` attribute
|
|
|
|
|
contains extra parameters passed to the ``content-type`` header on a file
|
|
|
|
|
upload.
|
|
|
|
|
|
|
|
|
|
* The new :setting:`FILE_UPLOAD_DIRECTORY_PERMISSIONS` setting controls
|
|
|
|
|
the file system permissions of directories created during file upload, like
|
|
|
|
|
:setting:`FILE_UPLOAD_PERMISSIONS` does for the files themselves.
|
|
|
|
|
|
2013-10-11 14:07:25 +02:00
|
|
|
|
* The :attr:`FileField.upload_to <django.db.models.FileField.upload_to>`
|
|
|
|
|
attribute is now optional. If it is omitted or given ``None`` or an empty
|
|
|
|
|
string, a subdirectory won't be used for storing the uploaded files.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
Forms
|
|
|
|
|
^^^^^
|
|
|
|
|
|
|
|
|
|
* The ``<label>`` and ``<input>`` tags rendered by
|
|
|
|
|
:class:`~django.forms.RadioSelect` and
|
|
|
|
|
:class:`~django.forms.CheckboxSelectMultiple` when looping over the radio
|
|
|
|
|
buttons or checkboxes now include ``for`` and ``id`` attributes, respectively.
|
|
|
|
|
Each radio button or checkbox includes an ``id_for_label`` attribute to
|
|
|
|
|
output the element's ID.
|
2013-07-30 14:24:13 +02:00
|
|
|
|
|
2013-07-20 23:49:33 +02:00
|
|
|
|
* :attr:`Field.choices<django.db.models.Field.choices>` now allows you to
|
|
|
|
|
customize the "empty choice" label by including a tuple with an empty string
|
|
|
|
|
or ``None`` for the key and the custom label as the value. The default blank
|
|
|
|
|
option ``"----------"`` will be omitted in this case.
|
|
|
|
|
|
2013-05-07 11:06:03 +02:00
|
|
|
|
* :class:`~django.forms.MultiValueField` allows optional subfields by setting
|
|
|
|
|
the ``require_all_fields`` argument to ``False``. The ``required`` attribute
|
|
|
|
|
for each individual field will be respected, and a new ``incomplete``
|
|
|
|
|
validation error will be raised when any required fields are empty.
|
|
|
|
|
|
2013-08-08 15:05:55 +02:00
|
|
|
|
* The :meth:`~django.forms.Form.clean` method on a form no longer needs to
|
|
|
|
|
return ``self.cleaned_data``. If it does return a changed dictionary then
|
2013-08-08 15:27:48 +02:00
|
|
|
|
that will still be used.
|
2013-08-08 15:05:55 +02:00
|
|
|
|
|
2013-11-18 18:24:56 +01:00
|
|
|
|
* After a temporary regression in Django 1.6, it's now possible again to make
|
|
|
|
|
:class:`~django.forms.TypedChoiceField` ``coerce`` method return an arbitrary
|
|
|
|
|
value.
|
|
|
|
|
|
2013-08-28 08:22:47 +02:00
|
|
|
|
* :attr:`SelectDateWidget.months
|
|
|
|
|
<django.forms.extras.widgets.SelectDateWidget.months>` can be used to
|
|
|
|
|
customize the wording of the months displayed in the select widget.
|
|
|
|
|
|
2013-05-24 08:02:07 +02:00
|
|
|
|
* The ``min_num`` and ``validate_min`` parameters were added to
|
|
|
|
|
:func:`~django.forms.formsets.formset_factory` to allow validating
|
|
|
|
|
a minimum number of submitted forms.
|
|
|
|
|
|
2013-07-20 21:25:27 +02:00
|
|
|
|
* The metaclasses used by ``Form`` and ``ModelForm`` have been reworked to
|
|
|
|
|
support more inheritance scenarios. The previous limitation that prevented
|
|
|
|
|
inheriting from both ``Form`` and ``ModelForm`` simultaneously have been
|
|
|
|
|
removed as long as ``ModelForm`` appears first in the MRO.
|
|
|
|
|
|
2013-10-14 17:42:33 +02:00
|
|
|
|
* It's now possible to opt-out from a ``Form`` field declared in a parent class
|
|
|
|
|
by shadowing it with a non-``Field`` value.
|
|
|
|
|
|
2013-11-11 18:56:01 +01:00
|
|
|
|
* The new :meth:`~django.forms.Form.add_error()` method allows adding errors
|
|
|
|
|
to specific form fields.
|
|
|
|
|
|
2012-11-17 13:14:12 +01:00
|
|
|
|
Internationalization
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The :attr:`django.middleware.locale.LocaleMiddleware.response_redirect_class`
|
|
|
|
|
attribute allows you to customize the redirects issued by the middleware.
|
|
|
|
|
|
2013-10-18 13:56:32 +02:00
|
|
|
|
* The :class:`~django.middleware.locale.LocaleMiddleware` now stores the user's
|
|
|
|
|
selected language with the session key ``_language``. Previously it was
|
|
|
|
|
stored with the key ``django_language``, but keys reserved for Django should
|
|
|
|
|
start with an underscore. For backwards compatibility ``django_language`` is
|
|
|
|
|
still read from in 1.7. Sessions will be migrated to the new ``_language``
|
|
|
|
|
key as they are written.
|
|
|
|
|
|
2013-11-02 20:01:17 +01:00
|
|
|
|
* The :ttag:`blocktrans` now supports a ``trimmed`` option. This
|
|
|
|
|
option will remove newline characters from the beginning and the end of the
|
|
|
|
|
content of the ``{% blocktrans %}`` tag, replace any whitespace at the
|
|
|
|
|
beginning and end of a line and merge all lines into one using a space
|
|
|
|
|
character to separate them. This is quite useful for indenting the content of
|
|
|
|
|
a ``{% blocktrans %}`` tag without having the indentation characters end up
|
|
|
|
|
in the corresponding entry in the PO file, which makes the translation
|
|
|
|
|
process easier.
|
|
|
|
|
|
2013-11-30 10:53:08 +01:00
|
|
|
|
* When you run :djadmin:`makemessages` from the root directory of your project,
|
|
|
|
|
any extracted strings will now be automatically distributed to the proper
|
|
|
|
|
app or project message file. See :ref:`how-to-create-language-files` for
|
|
|
|
|
details.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
Management Commands
|
|
|
|
|
^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The :djadminopt:`--no-color` option for ``django-admin.py`` allows you to
|
|
|
|
|
disable the colorization of management command output.
|
|
|
|
|
|
2012-08-01 03:49:01 +02:00
|
|
|
|
* The new :djadminopt:`--natural-foreign` and :djadminopt:`--natural-primary`
|
|
|
|
|
options for :djadmin:`dumpdata`, and the new ``use_natural_foreign_keys`` and
|
|
|
|
|
``use_natural_primary_keys`` arguments for ``serializers.serialize()``, allow
|
|
|
|
|
the use of natural primary keys when serializing.
|
|
|
|
|
|
2013-01-05 23:43:01 +01:00
|
|
|
|
* It is no longer necessary to provide the cache table name or the
|
|
|
|
|
:djadminopt:`--database` option for the :djadmin:`createcachetable` command.
|
|
|
|
|
Django takes this information from your settings file. If you have configured
|
|
|
|
|
multiple caches or multiple databases, all cache tables are created.
|
|
|
|
|
|
2013-11-04 23:28:38 +01:00
|
|
|
|
* The :djadmin:`runserver` command received several improvements:
|
2013-10-14 07:33:45 +02:00
|
|
|
|
|
2013-11-27 19:37:21 +01:00
|
|
|
|
* On BSD systems, including OS X, the development server will reload
|
2013-11-05 21:02:33 +01:00
|
|
|
|
immediately when a file is changed. Previously, it polled the filesystem
|
|
|
|
|
for changes every second. That caused a small delay before reloads and
|
|
|
|
|
reduced battery life on laptops.
|
2013-11-04 23:28:38 +01:00
|
|
|
|
|
|
|
|
|
* On Linux, the same improvements are available when pyinotify_ is
|
|
|
|
|
installed.
|
|
|
|
|
|
|
|
|
|
.. _pyinotify: https://pypi.python.org/pypi/pyinotify
|
|
|
|
|
|
2013-11-05 21:02:33 +01:00
|
|
|
|
* In addition, the development server automatically reloads when a
|
|
|
|
|
translation file is updated, i.e. after running
|
|
|
|
|
:djadmin:`compilemessages`.
|
2013-11-02 10:28:22 +01:00
|
|
|
|
|
2013-11-09 10:13:29 +01:00
|
|
|
|
* All HTTP requests are logged to the console, including requests for static
|
|
|
|
|
files or ``favicon.ico`` that used to be filtered out.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
Models
|
|
|
|
|
^^^^^^
|
|
|
|
|
|
2013-09-08 11:23:37 +02:00
|
|
|
|
* The :meth:`QuerySet.update_or_create()
|
|
|
|
|
<django.db.models.query.QuerySet.update_or_create>` method was added.
|
|
|
|
|
|
2013-08-01 17:31:34 +02:00
|
|
|
|
* The new :attr:`~django.db.models.Options.default_permissions` model
|
|
|
|
|
``Meta`` option allows you to customize (or disable) creation of the default
|
|
|
|
|
add, change, and delete permissions.
|
|
|
|
|
|
2013-09-08 11:23:37 +02:00
|
|
|
|
* :attr:`~django.db.models.Options.app_label` is no longer required for models
|
|
|
|
|
that are defined in a ``models`` package within an app.
|
|
|
|
|
|
2013-08-12 13:30:38 +02:00
|
|
|
|
* Explicit :class:`~django.db.models.OneToOneField` for
|
|
|
|
|
:ref:`multi-table-inheritance` are now discovered in abstract classes.
|
|
|
|
|
|
2013-08-20 07:52:32 +02:00
|
|
|
|
* Is it now possible to avoid creating a backward relation for
|
|
|
|
|
:class:`~django.db.models.OneToOneField` by setting its
|
|
|
|
|
:attr:`~django.db.models.ForeignKey.related_name` to
|
2013-11-05 05:11:51 +01:00
|
|
|
|
``'+'`` or ending it with ``'+'``.
|
2013-08-20 07:52:32 +02:00
|
|
|
|
|
2013-02-21 23:02:18 +01:00
|
|
|
|
* :class:`F expressions <django.db.models.F>` support the power operator
|
|
|
|
|
(``**``).
|
|
|
|
|
|
2013-11-21 18:14:16 +01:00
|
|
|
|
* The ``remove()`` and ``clear()`` methods of the related managers created by
|
|
|
|
|
``ForeignKey`` and ``GenericForeignKey`` now accept the ``bulk`` keyword
|
|
|
|
|
argument to control whether or not to perform operations in bulk
|
|
|
|
|
(i.e. using ``QuerySet.update()``). Defaults to ``True``.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
Signals
|
|
|
|
|
^^^^^^^
|
2013-06-04 22:41:49 +02:00
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
* The ``enter`` argument was added to the
|
|
|
|
|
:data:`~django.test.signals.setting_changed` signal.
|
|
|
|
|
|
2013-11-05 05:11:51 +01:00
|
|
|
|
* The model signals can be now be connected to using a ``str`` of the
|
|
|
|
|
``'app_label.ModelName'`` form – just like related fields – to lazily
|
|
|
|
|
reference their senders.
|
|
|
|
|
|
2013-08-27 15:39:56 +02:00
|
|
|
|
Templates
|
|
|
|
|
^^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The :meth:`Context.push() <django.template.Context.push>` method now returns
|
|
|
|
|
a context manager which automatically calls :meth:`pop()
|
|
|
|
|
<django.template.Context.pop>` upon exiting the ``with`` statement.
|
|
|
|
|
Additionally, :meth:`push() <django.template.Context.push>` now accepts
|
|
|
|
|
parameters that are passed to the ``dict`` constructor used to build the new
|
|
|
|
|
context level.
|
2013-08-10 10:13:41 +02:00
|
|
|
|
|
2013-08-14 16:14:32 +02:00
|
|
|
|
* The :ttag:`widthratio` template tag now accepts an "as" parameter to capture
|
|
|
|
|
the result in a variable.
|
|
|
|
|
|
2013-08-28 14:17:20 +02:00
|
|
|
|
* The :ttag:`include` template tag will now also accept anything with a
|
|
|
|
|
``render()`` method (such as a ``Template``) as an argument. String
|
|
|
|
|
arguments will be looked up using
|
|
|
|
|
:func:`~django.template.loader.get_template` as always.
|
|
|
|
|
|
2013-08-29 10:58:56 +02:00
|
|
|
|
* It is now possible to :ttag:`include` templates recursively.
|
|
|
|
|
|
2013-08-30 21:08:40 +02:00
|
|
|
|
* Template objects now have an origin attribute set when
|
|
|
|
|
:setting:`TEMPLATE_DEBUG` is ``True``. This allows template origins to be
|
|
|
|
|
inspected and logged outside of the ``django.template`` infrastructure.
|
|
|
|
|
|
2013-10-23 16:56:13 +02:00
|
|
|
|
* ``TypeError`` exceptions are no longer silenced when raised during the
|
2013-09-08 15:07:12 +02:00
|
|
|
|
rendering of a template.
|
|
|
|
|
|
2013-09-15 23:51:24 +02:00
|
|
|
|
* The following functions now accept a ``dirs`` parameter which is a list or
|
|
|
|
|
tuple to override :setting:`TEMPLATE_DIRS`:
|
|
|
|
|
|
|
|
|
|
* :func:`django.template.loader.get_template()`
|
|
|
|
|
* :func:`django.template.loader.select_template()`
|
|
|
|
|
* :func:`django.shortcuts.render()`
|
|
|
|
|
* :func:`django.shortcuts.render_to_response()`
|
|
|
|
|
|
2013-09-22 20:41:24 +02:00
|
|
|
|
* The :tfilter:`time` filter now accepts timzone-related :ref:`format
|
|
|
|
|
specifiers <date-and-time-formatting-specifiers>` ``'e'``, ``'O'`` , ``'T'``
|
|
|
|
|
and ``'Z'`` and is able to digest :ref:`time-zone-aware
|
|
|
|
|
<naive_vs_aware_datetimes>` ``datetime`` instances performing the expected
|
|
|
|
|
rendering.
|
|
|
|
|
|
2013-10-03 23:36:21 +02:00
|
|
|
|
* The :ttag:`cache` tag will now try to use the cache called
|
|
|
|
|
"template_fragments" if it exists and fall back to using the default cache
|
|
|
|
|
otherwise. It also now accepts an optional ``using`` keyword argument to
|
|
|
|
|
control which cache it uses.
|
|
|
|
|
|
2013-10-08 20:30:29 +02:00
|
|
|
|
Requests
|
|
|
|
|
^^^^^^^^
|
|
|
|
|
|
|
|
|
|
* The new :attr:`HttpRequest.scheme <django.http.HttpRequest.scheme>` attribute
|
|
|
|
|
specifies the scheme of the request (``http`` or ``https`` normally).
|
|
|
|
|
|
2013-09-10 15:49:39 +02:00
|
|
|
|
Tests
|
|
|
|
|
^^^^^
|
|
|
|
|
|
|
|
|
|
* :class:`~django.test.runner.DiscoverRunner` has two new attributes,
|
|
|
|
|
:attr:`~django.test.runner.DiscoverRunner.test_suite` and
|
|
|
|
|
:attr:`~django.test.runner.DiscoverRunner.test_runner`, which facilitate
|
|
|
|
|
overriding the way tests are collected and run.
|
|
|
|
|
|
2013-09-07 23:13:57 +02:00
|
|
|
|
* The ``fetch_redirect_response`` argument was added to
|
|
|
|
|
:meth:`~django.test.SimpleTestCase.assertRedirects`. Since the test
|
|
|
|
|
client can't fetch externals URLs, this allows you to use ``assertRedirects``
|
|
|
|
|
with redirects that aren't part of your Django app.
|
|
|
|
|
|
2013-10-28 20:34:09 +01:00
|
|
|
|
* Correct handling of scheme when making comparisons in
|
|
|
|
|
:meth:`~django.test.SimpleTestCase.assertRedirects`.
|
|
|
|
|
|
2013-10-28 15:00:54 +01:00
|
|
|
|
* The ``secure`` argument was added to all the request methods of
|
|
|
|
|
:class:`~django.test.Client`. If ``True``, the request will be made
|
|
|
|
|
through HTTPS.
|
|
|
|
|
|
2013-10-29 18:31:54 +01:00
|
|
|
|
* Requests made with :meth:`Client.login() <django.test.Client.login>` and
|
|
|
|
|
:meth:`Client.logout() <django.test.Client.logout>` respect defaults defined
|
|
|
|
|
in :class:`~django.test.Client` instantiation and are processed through
|
|
|
|
|
middleware.
|
|
|
|
|
|
2013-07-01 13:53:06 +02:00
|
|
|
|
Backwards incompatible changes in 1.7
|
|
|
|
|
=====================================
|
|
|
|
|
|
|
|
|
|
.. warning::
|
|
|
|
|
|
|
|
|
|
In addition to the changes outlined in this section, be sure to review the
|
|
|
|
|
:doc:`deprecation plan </internals/deprecation>` for any features that
|
|
|
|
|
have been removed. If you haven't updated your code within the
|
|
|
|
|
deprecation timeline for a given feature, its removal may appear as a
|
|
|
|
|
backwards incompatible change.
|
|
|
|
|
|
2013-07-30 13:34:31 +02:00
|
|
|
|
allow_syncdb/allow_migrate
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
While Django will still look at ``allow_syncdb`` methods even though they
|
|
|
|
|
should be renamed to ``allow_migrate``, there is a subtle difference in which
|
|
|
|
|
models get passed to these methods.
|
|
|
|
|
|
|
|
|
|
For apps with migrations, ``allow_migrate`` will now get passed
|
|
|
|
|
:ref:`historical models <historical-models>`, which are special versioned models
|
|
|
|
|
without custom attributes, methods or managers. Make sure your ``allow_migrate``
|
|
|
|
|
methods are only referring to fields or other items in ``model._meta``.
|
|
|
|
|
|
2013-11-23 17:50:28 +01:00
|
|
|
|
Behavior of ``LocMemCache`` regarding pickle errors
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
An inconsistency existed in previous versions of Django regarding how pickle
|
|
|
|
|
errors are handled by different cache backends.
|
|
|
|
|
``django.core.cache.backends.locmem.LocMemCache`` used to fail silently when
|
|
|
|
|
such an error occurs, which is inconsistent with other backends and leads to
|
|
|
|
|
cache-specific errors. This has been fixed in Django 1.7, see
|
|
|
|
|
`Ticket #21200`_ for more details.
|
|
|
|
|
|
|
|
|
|
.. _Ticket #21200: https://code.djangoproject.com/ticket/21200
|
|
|
|
|
|
2013-09-30 07:05:43 +02:00
|
|
|
|
Passing ``None`` to ``Manager.db_manager()``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
In previous versions of Django, it was possible to use
|
|
|
|
|
``db_manager(using=None)`` on a model manager instance to obtain a manager
|
|
|
|
|
instance using default routing behavior, overriding any manually specified
|
|
|
|
|
database routing. In Django 1.7, a value of ``None`` passed to db_manager will
|
|
|
|
|
produce a router that *retains* any manually assigned database routing -- the
|
|
|
|
|
manager will *not* be reset. This was necessary to resolve an inconsistency in
|
|
|
|
|
the way routing information cascaded over joins. See `Ticket #13724`_ for more
|
|
|
|
|
details.
|
|
|
|
|
|
|
|
|
|
.. _Ticket #13724: https://code.djangoproject.com/ticket/13724
|
|
|
|
|
|
2013-09-08 09:04:31 +02:00
|
|
|
|
pytz may be required
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
If your project handles datetimes before 1970 or after 2037 and Django raises
|
|
|
|
|
a :exc:`~exceptions.ValueError` when encountering them, you will have to
|
|
|
|
|
install pytz_. You may be affected by this problem if you use Django's time
|
|
|
|
|
zone-related date formats or :mod:`django.contrib.syndication`.
|
|
|
|
|
|
2013-09-27 01:35:53 +02:00
|
|
|
|
``remove()`` and ``clear()`` methods of related managers
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The ``remove()`` and ``clear()`` methods of the related managers created by
|
|
|
|
|
``ForeignKey``, ``GenericForeignKey``, and ``ManyToManyField`` suffered from a
|
|
|
|
|
number of issues. Some operations ran multiple data modifying queries without
|
|
|
|
|
wrapping them in a transaction, and some operations didn't respect default
|
|
|
|
|
filtering when it was present (i.e. when the default manager on the related
|
|
|
|
|
model implemented a custom ``get_queryset()``).
|
|
|
|
|
|
|
|
|
|
Fixing the issues introduced some backward incompatible changes:
|
|
|
|
|
|
|
|
|
|
- The default implementation of ``remove()`` for ``ForeignKey`` related managers
|
|
|
|
|
changed from a series of ``Model.save()`` calls to a single
|
|
|
|
|
``QuerySet.update()`` call. The change means that ``pre_save`` and
|
2013-11-21 18:14:16 +01:00
|
|
|
|
``post_save`` signals aren't sent anymore. You can use the ``bulk=False``
|
|
|
|
|
keyword argument to revert to the previous behavior.
|
2013-09-27 01:35:53 +02:00
|
|
|
|
|
|
|
|
|
- The ``remove()`` and ``clear()`` methods for ``GenericForeignKey`` related
|
|
|
|
|
managers now perform bulk delete. The ``Model.delete()`` method isn't called
|
2013-11-21 18:14:16 +01:00
|
|
|
|
on each instance anymore. You can use the ``bulk=False`` keyword argument to
|
|
|
|
|
revert to the previous behavior.
|
2013-09-27 01:35:53 +02:00
|
|
|
|
|
|
|
|
|
- The ``remove()`` and ``clear()`` methods for ``ManyToManyField`` related
|
|
|
|
|
managers perform nested queries when filtering is involved, which may or
|
|
|
|
|
may not be an issue depending on your database and your data itself.
|
|
|
|
|
See :ref:`this note <nested-queries-performance>` for more details.
|
|
|
|
|
|
2013-09-08 09:04:31 +02:00
|
|
|
|
.. _pytz: https://pypi.python.org/pypi/pytz/
|
|
|
|
|
|
2013-04-19 19:20:23 +02:00
|
|
|
|
Miscellaneous
|
|
|
|
|
~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
* The :meth:`django.core.files.uploadhandler.FileUploadHandler.new_file()`
|
|
|
|
|
method is now passed an additional ``content_type_extra`` parameter. If you
|
|
|
|
|
have a custom :class:`~django.core.files.uploadhandler.FileUploadHandler`
|
|
|
|
|
that implements ``new_file()``, be sure it accepts this new parameter.
|
|
|
|
|
|
2013-08-05 18:23:26 +02:00
|
|
|
|
* :class:`ModelFormSet<django.forms.models.BaseModelFormSet>`’s no longer
|
2013-07-12 15:52:18 +02:00
|
|
|
|
delete instances when ``save(commit=False)`` is called. See
|
|
|
|
|
:attr:`~django.forms.formsets.BaseFormSet.can_delete` for instructions on how
|
|
|
|
|
to manually delete objects from deleted forms.
|
|
|
|
|
|
2013-02-23 20:34:59 +01:00
|
|
|
|
* Loading empty fixtures emits a ``RuntimeWarning`` rather than raising
|
|
|
|
|
:class:`~django.core.management.CommandError`.
|
|
|
|
|
|
2013-07-31 13:22:38 +02:00
|
|
|
|
* :func:`django.contrib.staticfiles.views.serve` will now raise an
|
2013-07-31 09:11:49 +02:00
|
|
|
|
:exc:`~django.http.Http404` exception instead of
|
2013-07-31 13:22:38 +02:00
|
|
|
|
:exc:`~django.core.exceptions.ImproperlyConfigured` when :setting:`DEBUG`
|
|
|
|
|
is ``False``. This change removes the need to conditionally add the view to
|
2013-07-31 09:11:49 +02:00
|
|
|
|
your root URLconf, which in turn makes it safe to reverse by name. It also
|
|
|
|
|
removes the ability for visitors to generate spurious HTTP 500 errors by
|
|
|
|
|
requesting static files that don't exist or haven't been collected yet.
|
|
|
|
|
|
2013-08-07 08:51:32 +02:00
|
|
|
|
* The :meth:`django.db.models.Model.__eq__` method is now defined in a
|
|
|
|
|
way where instances of a proxy model and its base model are considered
|
|
|
|
|
equal when primary keys match. Previously only instances of exact same
|
|
|
|
|
class were considered equal on primary key match.
|
|
|
|
|
|
2013-08-14 10:05:01 +02:00
|
|
|
|
* The :meth:`django.db.models.Model.__eq__` method has changed such that
|
|
|
|
|
two ``Model`` instances without primary key values won't be considered
|
|
|
|
|
equal (unless they are the same instance).
|
2013-08-27 15:39:56 +02:00
|
|
|
|
|
2013-08-14 10:05:01 +02:00
|
|
|
|
* The :meth:`django.db.models.Model.__hash__` will now raise ``TypeError``
|
|
|
|
|
when called on an instance without a primary key value. This is done to
|
|
|
|
|
avoid mutable ``__hash__`` values in containers.
|
|
|
|
|
|
2013-09-09 20:22:29 +02:00
|
|
|
|
* :class:`~django.db.models.AutoField` columns in SQLite databases will now be
|
|
|
|
|
created using the ``AUTOINCREMENT`` option, which guarantees monotonic
|
2013-09-06 18:18:16 +02:00
|
|
|
|
increments. This will cause primary key numbering behavior to change on
|
2013-09-09 20:22:29 +02:00
|
|
|
|
SQLite, becoming consistent with most other SQL databases. This will only
|
|
|
|
|
apply to newly created tables. If you have a database created with an older
|
|
|
|
|
version of Django, you will need to migrate it to take advantage of this
|
|
|
|
|
feature. For example, you could do the following:
|
|
|
|
|
|
|
|
|
|
#) Use :djadmin:`dumpdata` to save your data.
|
|
|
|
|
#) Rename the existing database file (keep it as a backup).
|
|
|
|
|
#) Run :djadmin:`migrate` to create the updated schema.
|
|
|
|
|
#) Use :djadmin:`loaddata` to import the fixtures you exported in (1).
|
2013-09-06 18:18:16 +02:00
|
|
|
|
|
2013-08-29 02:03:21 +02:00
|
|
|
|
* ``django.contrib.auth.models.AbstractUser`` no longer defines a
|
|
|
|
|
:meth:`~django.db.models.Model.get_absolute_url()` method. The old definition
|
|
|
|
|
returned ``"/users/%s/" % urlquote(self.username)`` which was arbitrary
|
|
|
|
|
since applications may or may not define such a url in ``urlpatterns``.
|
|
|
|
|
Define a ``get_absolute_url()`` method on your own custom user object or use
|
|
|
|
|
:setting:`ABSOLUTE_URL_OVERRIDES` if you want a URL for your user.
|
|
|
|
|
|
2013-06-01 19:24:46 +02:00
|
|
|
|
* The static asset-serving functionality of the
|
|
|
|
|
:class:`django.test.LiveServerTestCase` class has been simplified: Now it's
|
|
|
|
|
only able to serve content already present in :setting:`STATIC_ROOT` when
|
|
|
|
|
tests are run. The ability to transparently serve all the static assets
|
|
|
|
|
(similarly to what one gets with :setting:`DEBUG = True <DEBUG>` at
|
|
|
|
|
development-time) has been moved to a new class that lives in the
|
|
|
|
|
``staticfiles`` application (the one actually in charge of such feature):
|
|
|
|
|
:class:`django.contrib.staticfiles.testing.StaticLiveServerCase`. In other
|
|
|
|
|
words, ``LiveServerTestCase`` itself is less powerful but at the same time
|
|
|
|
|
has less magic.
|
|
|
|
|
|
|
|
|
|
Rationale behind this is removal of dependency of non-contrib code on
|
|
|
|
|
contrib applications.
|
|
|
|
|
|
2013-09-19 10:38:56 +02:00
|
|
|
|
* The old cache URI syntax (e.g. ``"locmem://"``) is no longer supported. It
|
|
|
|
|
still worked, even though it was not documented or officially supported. If
|
|
|
|
|
you're still using it, please update to the current :setting:`CACHES` syntax.
|
|
|
|
|
|
2013-07-20 21:25:27 +02:00
|
|
|
|
* The default ordering of ``Form`` fields in case of inheritance has changed to
|
|
|
|
|
follow normal Python MRO. Fields are now discovered by iterating through the
|
|
|
|
|
MRO in reverse with the topmost class coming last. This only affects you if
|
|
|
|
|
you relied on the default field ordering while having fields defined on both
|
|
|
|
|
the current class *and* on a parent ``Form``.
|
|
|
|
|
|
2013-10-31 17:27:21 +01:00
|
|
|
|
* The ``required`` argument of
|
|
|
|
|
:class:`~django.forms.extras.widgets.SelectDateWidget` has been removed.
|
|
|
|
|
This widget now respects the form field's ``is_required`` attribute like
|
|
|
|
|
other widgets.
|
|
|
|
|
|
2013-10-15 14:15:02 +02:00
|
|
|
|
* :meth:`~django.db.models.query.QuerySet.select_related` now chains in the
|
|
|
|
|
same way as other similar calls like ``prefetch_related``. That is,
|
|
|
|
|
``select_related('foo', 'bar')`` is equivalent to
|
|
|
|
|
``select_related('foo').select_related('bar')``. Previously the latter would
|
|
|
|
|
have been equivalent to ``select_related('bar')``.
|
|
|
|
|
|
2013-07-01 13:53:06 +02:00
|
|
|
|
Features deprecated in 1.7
|
|
|
|
|
==========================
|
|
|
|
|
|
2013-10-19 00:49:24 +02:00
|
|
|
|
``django.core.cache.get_cache``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
:func:`django.core.cache.get_cache` has been supplanted by
|
|
|
|
|
:data:`django.core.cache.caches`.
|
|
|
|
|
|
2013-07-29 15:50:58 +02:00
|
|
|
|
``django.utils.dictconfig``/``django.utils.importlib``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2013-07-01 22:50:58 +02:00
|
|
|
|
|
2013-07-29 15:50:58 +02:00
|
|
|
|
``django.utils.dictconfig`` and ``django.utils.importlib`` were copies of
|
|
|
|
|
respectively :mod:`logging.config` and :mod:`importlib` provided for Python
|
|
|
|
|
versions prior to 2.7. They have been deprecated.
|
2013-07-01 22:50:58 +02:00
|
|
|
|
|
2013-09-08 09:04:31 +02:00
|
|
|
|
``django.utils.tzinfo``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
``django.utils.tzinfo`` provided two :class:`~datetime.tzinfo` subclasses,
|
|
|
|
|
``LocalTimezone`` and ``FixedOffset``. They've been deprecated in favor of
|
|
|
|
|
more correct alternatives provided by :mod:`django.utils.timezone`,
|
|
|
|
|
:func:`django.utils.timezone.get_default_timezone` and
|
|
|
|
|
:func:`django.utils.timezone.get_fixed_timezone`.
|
|
|
|
|
|
2013-07-01 13:53:06 +02:00
|
|
|
|
``django.utils.unittest``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
``django.utils.unittest`` provided uniform access to the ``unittest2`` library
|
|
|
|
|
on all Python versions. Since ``unittest2`` became the standard library's
|
|
|
|
|
:mod:`unittest` module in Python 2.7, and Django 1.7 drops support for older
|
|
|
|
|
Python versions, this module isn't useful anymore. It has been deprecated. Use
|
|
|
|
|
:mod:`unittest` instead.
|
2013-07-16 15:10:04 +02:00
|
|
|
|
|
2013-08-03 07:41:15 +02:00
|
|
|
|
``django.utils.datastructures.SortedDict``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
As :class:`~collections.OrderedDict` was added to the standard library in
|
|
|
|
|
Python 2.7, :class:`~django.utils.datastructures.SortedDict` is no longer
|
|
|
|
|
needed and has been deprecated.
|
|
|
|
|
|
2013-07-16 15:10:04 +02:00
|
|
|
|
Custom SQL location for models package
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
Previously, if models were organized in a package (``myapp/models/``) rather
|
|
|
|
|
than simply ``myapp/models.py``, Django would look for :ref:`initial SQL data
|
|
|
|
|
<initial-sql>` in ``myapp/models/sql/``. This bug has been fixed so that Django
|
|
|
|
|
will search ``myapp/sql/`` as documented. The old location will continue to
|
|
|
|
|
work until Django 1.9.
|
2013-07-31 07:52:11 +02:00
|
|
|
|
|
2013-09-04 03:01:45 +02:00
|
|
|
|
``declared_fieldsets`` attribute on ``ModelAdmin``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2013-07-31 07:52:11 +02:00
|
|
|
|
|
2013-09-04 03:01:45 +02:00
|
|
|
|
``ModelAdmin.declared_fieldsets`` has been deprecated. Despite being a private
|
|
|
|
|
API, it will go through a regular deprecation path. This attribute was mostly
|
|
|
|
|
used by methods that bypassed ``ModelAdmin.get_fieldsets()`` but this was
|
|
|
|
|
considered a bug and has been addressed.
|
2013-08-10 21:00:12 +02:00
|
|
|
|
|
|
|
|
|
``syncdb``
|
|
|
|
|
~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The ``syncdb`` command has been deprecated in favour of the new ``migrate``
|
|
|
|
|
command. ``migrate`` takes the same arguments as ``syncdb`` used to plus a few
|
|
|
|
|
more, so it's safe to just change the name you're calling and nothing else.
|
2013-09-16 18:52:05 +02:00
|
|
|
|
|
|
|
|
|
``util`` modules renamed to ``utils``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The following instances of ``util.py`` in the Django codebase have been renamed
|
|
|
|
|
to ``utils.py`` in an effort to unify all util and utils references:
|
|
|
|
|
|
|
|
|
|
* ``django.contrib.admin.util``
|
|
|
|
|
* ``django.contrib.gis.db.backends.util``
|
|
|
|
|
* ``django.db.backends.util``
|
|
|
|
|
* ``django.forms.util``
|
2013-09-04 03:01:45 +02:00
|
|
|
|
|
|
|
|
|
``get_formsets`` method on ``ModelAdmin``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
``ModelAdmin.get_formsets`` has been deprecated in favor of the new
|
|
|
|
|
:meth:`~django.contrib.admin.ModelAdmin.get_formsets_with_inlines`, in order to
|
|
|
|
|
better handle the case of selecting showing inlines on a ``ModelAdmin``.
|
2013-09-28 10:22:46 +02:00
|
|
|
|
|
|
|
|
|
``IPAddressField``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The :class:`django.db.models.IPAddressField` and
|
|
|
|
|
:class:`django.forms.IPAddressField` fields have been deprecated in favor of
|
|
|
|
|
:class:`django.db.models.GenericIPAddressField` and
|
|
|
|
|
:class:`django.forms.GenericIPAddressField`.
|
|
|
|
|
|
2013-09-23 18:40:19 +02:00
|
|
|
|
``BaseMemcachedCache._get_memcache_timeout`` method
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The ``BaseMemcachedCache._get_memcache_timeout()`` method has been renamed to
|
|
|
|
|
``get_backend_timeout()``. Despite being a private API, it will go through the
|
|
|
|
|
normal deprecation.
|
2012-08-01 03:49:01 +02:00
|
|
|
|
|
|
|
|
|
Natural key serialization options
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The ``--natural`` and ``-n`` options for :djadmin:`dumpdata` have been
|
|
|
|
|
deprecated. Use :djadminopt:`--natural-foreign` instead.
|
|
|
|
|
|
|
|
|
|
Similarly, the ``use_natural_keys`` argument for ``serializers.serialize()``
|
|
|
|
|
has been deprecated. Use ``use_natural_foreign_keys`` instead.
|
2013-10-15 22:36:49 +02:00
|
|
|
|
|
|
|
|
|
Merging of ``POST`` and ``GET`` arguments into ``WSGIRequest.REQUEST``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
It was already strongly suggested that you use ``GET`` and ``POST`` instead of
|
|
|
|
|
``REQUEST``, because the former are more explicit. The property ``REQUEST`` is
|
|
|
|
|
deprecated and will be removed in Django 1.9.
|
|
|
|
|
|
|
|
|
|
``django.utils.datastructures.MergeDict`` class
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
``MergeDict`` exists primarily to support merging ``POST`` and ``GET``
|
|
|
|
|
arguments into a ``REQUEST`` property on ``WSGIRequest``. To merge
|
|
|
|
|
dictionaries, use ``dict.update()`` instead. The class ``MergeDict`` is
|
|
|
|
|
deprecated and will be removed in Django 1.9.
|
2013-11-04 18:31:34 +01:00
|
|
|
|
|
2013-11-11 09:05:17 +01:00
|
|
|
|
Language codes ``zh-cn``, ``zh-tw`` and ``fy-nl``
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The currently used language codes for Simplified Chinese ``zh-cn``,
|
|
|
|
|
Traditional Chinese ``zh-tw`` and (Western) Frysian ``fy-nl`` are deprecated
|
|
|
|
|
and should be replaced by the language codes ``zh-hans``, ``zh-hant`` and
|
|
|
|
|
``fy`` respectively. If you use these language codes, you should rename the
|
|
|
|
|
locale directories and update your settings to reflect these changes. The
|
|
|
|
|
deprecated language codes will be removed in Django 1.9.
|
2013-11-01 21:15:41 +01:00
|
|
|
|
|
|
|
|
|
``django.utils.functional.memoize`` function
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
The function ``memoize`` is deprecated and should be replaced by the
|
|
|
|
|
``functools.lru_cache`` decorator (available from Python 3.2 onwards).
|
|
|
|
|
|
|
|
|
|
Django ships a backport of this decorator for older Python versions and it's
|
|
|
|
|
available at ``django.utils.lru_cache.lru_cache``. The deprecated function will
|
|
|
|
|
be removed in Django 1.9.
|