#28534: Changing JSONField on inline in admin doesn't always trigger change
-----------------------------+-------------------------------------
     Reporter:  john-parton  |                    Owner:  hui shang
         Type:  Bug          |                   Status:  assigned
    Component:  Forms        |                  Version:  1.11
     Severity:  Normal       |               Resolution:
     Keywords:               |             Triage Stage:  Accepted
    Has patch:  1            |      Needs documentation:  0
  Needs tests:  0            |  Patch needs improvement:  1
Easy pickings:  0            |                    UI/UX:  0
-----------------------------+-------------------------------------

Comment (by hui shang):

 Replying to [comment:6 john-parton]:
 > Replying to [comment:5 hui shang]:
 > > [https://github.com/django/django/pull/8989#### PR]
 > >
 > > Hi, @john-partonm, for (1),  json.dumps works well, but I think str()
 is a good choice too, so I use it.
 >
 > Does str() always sort dictionary keys? I'm not totally sure, but under
 certain circumstances I think your fix might flag {'a': 1, 'b': 2} as
 being different from {'b': 2, 'a': 1}.
 >
 > Thanks for the quick response and your hard work!
 >
 > EDIT:
 >
 > At least with Python3.6, the string representation of two dicts can
 differ:
 >
 > {{{
 >   Python 3.6.1 (default, Dec 2015, 13:05:11)
 >   [GCC 4.8.2] on linux
 >    left = {}
 >    left['a'] = 1
 >    left['b'] = 2
 >    right = {}
 >    right['b'] = 2
 >    right['a'] = 1
 > str(left) == str(right)
 > => False
 > }}}

 Yes, you are right, thank you for the explanation.  I have changed the
 comparison from str() to json.dumps

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28534#comment:8>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.b2135be492d6478e5a2db83d560c4344%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to