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

Option to preserve ordering as written #58

Open
shacker opened this issue Sep 3, 2021 · 0 comments
Open

Option to preserve ordering as written #58

shacker opened this issue Sep 3, 2021 · 0 comments

Comments

@shacker
Copy link

shacker commented Sep 3, 2021

  • django-json-widget version: 1.1.1
  • Django version: 3.1.x
  • Python version: 3.9
  • Operating System: Mac, Linux

Description

Expected: Order of object keys is preserved as written

What actually happens: On save, django-json-widget re-orders the keys in the top-level dictionary and in sub-dictionaries arbitrarily. I know that the order of contents of python dictionaries was not guaranteed in the past, but on later versions of python it is, and I am running a version of python that should preserve dictionary ordering. Oh, but this is JSON, not Python, and I see that JSON objects still do not guarantee ordering.

Is there any way to prevent this for some models where it's undesirable? In my use case, I'm rendering Swagger (OAS) docs with Redoc and I want to control the order of endpoints listed in the UI. Redoc says "We preserve the order in which they're presented" but I can't control that because this widget re-orders them on save.

@shacker shacker changed the title Option to prevent alphabetization Option to preserve ordering as written Sep 3, 2021
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

1 participant