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

Don't sort keys by default in tojson when rendering profile forms #787

Merged
merged 1 commit into from
Sep 19, 2023

Conversation

yuvipanda
Copy link
Collaborator

jinja2's tojson sorts keys in dicts by default. This was useful in the time when python's dicts were not ordered. However, now that dicts are ordered in python, this screws it up. Since profiles are dicts, ordering does matter - they should be displayed to the user in the order that the admin sets them. This allows template writers to use |tojson on the profile_list (to be read by JS) without worrying about ordering getting mangled. Template writers can still sort keys by explicitly using |dictsort in their template

@yuvipanda yuvipanda requested a review from minrk September 19, 2023 00:58
jinja2's tojson sorts keys in dicts by default. This was useful
in the time when python's dicts were not ordered. However, now that
dicts are ordered in python, this screws it up. Since profiles are
dicts, ordering *does* matter - they should be displayed to the user
in the order that the admin sets them. This allows template writers
to use `|tojson` on the profile_list (to be read by JS)
without worrying about ordering getting mangled. Template writers
can still sort keys by explicitly using `|dictsort` in their
template
@minrk minrk merged commit d60146f into jupyterhub:main Sep 19, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants