Open rgupta2 opened 6 years ago
Thanks for the report!
Are you trying to store the array ["HH"]
or the string "[\"HH\"]"
?
I can't replicate the specific behavior you're describing. In the admin interface, I enter "[\"HH\"]"
, save, edit some other other field, save again, and do not see additional backslashes added (like "[\\\"HH\\\"]"
) -- I just continue to see "[\"HH\"]"
. What versions are you using for django and this package? Are you using additional packages or custom forms in your admin?
I do see a difference between the admin widget and a widget in a template, where the admin has "[\"HH\"]"
and the template is showing ["HH"]
, so I'll have to think through whether consistency is needed and what should be happening.
If I have ["HH"] stored in a jsonfield, when I edit the corresponding model, using django-prettyjson shows it with backslashes in attached screenshot
When user saves the same string again, the backslashes become part of the json data. This means everytime a user clicks on change form to edit some other field, the json field will continue to get backslashes added.
This is not a good experience. Ideally, there should be a conversion to show string without backslashes to the user