Code

Ticket #10150: model_to_sorted_dict.diff

File model_to_sorted_dict.diff, 500 bytes (added by Rob Hudson <treborhudson@…>, 5 years ago)

One line patch that replaces uses SortedDict in favor of {}

Line 
1diff --git a/django/forms/models.py b/django/forms/models.py
2index 01bd912..f187183 100644
3--- a/django/forms/models.py
4+++ b/django/forms/models.py
5@@ -117,7 +117,7 @@ def model_to_dict(instance, fields=None, exclude=None):
6     # avoid a circular import
7     from django.db.models.fields.related import ManyToManyField, OneToOneField
8     opts = instance._meta
9-    data = {}
10+    data = SortedDict()
11     for f in opts.fields + opts.many_to_many:
12         if not f.editable:
13             continue