django-prettyjson icon indicating copy to clipboard operation
django-prettyjson copied to clipboard

edit format needed without quotes

Open rgupta2 opened this issue 6 years ago • 1 comments

If I have ["HH"] stored in a jsonfield, when I edit the corresponding model, using django-prettyjson shows it with backslashes in attached screenshot

screen shot 2018-07-07 at 6 56 51 pm

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

rgupta2 avatar Jul 07 '18 13:07 rgupta2

Thanks for the report!

  1. Are you trying to store the array ["HH"] or the string "[\"HH\"]"?

  2. 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?

  3. 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.

kevinmickey avatar Aug 07 '18 15:08 kevinmickey