From c5c8751147d41913a05e86097ea29ccc9fc2e5be Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Tue, 17 Mar 2015 13:41:11 -0400 Subject: [PATCH] Refs #24487 -- Added upgrade tips about removal of SortedDict. Thanks Pascal Chambon for the initial patch. --- docs/releases/1.7.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 72e8bbe4c7a..f00e7bd7157 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -1512,6 +1512,22 @@ Python versions, this module isn't useful anymore. It has been deprecated. Use As :class:`~collections.OrderedDict` was added to the standard library in Python 2.7, ``SortedDict`` is no longer needed and has been deprecated. +The two additional, deprecated methods provided by ``SortedDict`` (``insert()`` +and ``value_for_index()``) have been removed. If you relied on these methods to +alter structures like form fields, you should now treat these ``OrderedDict``\s +as immutable objects and override them to change their content. + +For example, you might want to override ``MyFormClass.base_fields`` (although +this attribute isn't considered a public API) to change the ordering of fields +for all ``MyFormClass`` instances; or similarly, you could override +``self.fields`` from inside ``MyFormClass.__init__()``, to change the fields +for a particular form instance. For example (from Django itself):: + + PasswordChangeForm.base_fields = OrderedDict( + (k, PasswordChangeForm.base_fields[k]) + for k in ['old_password', 'new_password1', 'new_password2'] + ) + Custom SQL location for models package ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~