About The Order of JSON Fields
Since Python 3.6, the standard dict
type maintains insertion order. So you can use a simple dictionary with JsonResponse
and it will preserve the order of fields:
1 2 3 4 5 6 7 8 9 |
|
Previously, you would have had to use OrderedDict
for that:
1 2 3 4 5 6 7 8 9 10 |
|
Tips and Tricks Programming Django 4.2 Django 3.2 Django 2.2 Python 3
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django GDPR Cookie Consent app
For Django websites that use cookies.