Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

edit format needed without quotes #17

Open
rgupta2 opened this issue Jul 7, 2018 · 1 comment
Open

edit format needed without quotes #17

rgupta2 opened this issue Jul 7, 2018 · 1 comment

Comments

@rgupta2
Copy link

rgupta2 commented Jul 7, 2018

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

@kevinmickey
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants