jupyterhub / kubespawner

Kubernetes spawner for JupyterHub
https://jupyterhub-kubespawner.readthedocs.io
BSD 3-Clause "New" or "Revised" License
543 stars 304 forks source link

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

Closed yuvipanda closed 1 year ago

yuvipanda commented 1 year ago

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