Serialized output should be ordered according to fields-definition

Seph Soliman avatarSeph Soliman created an issue

I've defined the following fields to be output:

class MediaHandler(AnonymousBaseHandler):
    model = Media
    fields = ('id', 'def_type', 'title', 'description', 'tags', 'formats', 'thumbnails', 'files', 'def_media')

However, the fields are not outputted in that order but like this:

"files": [
	{
		"format": "Unknown format", 
		"size": 19496210
	}
], 
"description": "Michael underviser", 
"tags": [
	{
		"count": null, 
		"name": "guitar"
	}, 
	{
		"count": null, 
		"name": "michael"
	}, 
	{
		"count": null, 
		"name": "stuff"
	}, 
	{
		"count": null, 
		"name": "undervisning"
	}
], 
"title": "Guitar und(...)"

This really isn't an issue for me other than when I'm debugging the output (i'd love to have id, type and title to be first). For XML this may be relevant for others to have it ordered in a certain way.

Since the fields are specified using tuples, we should be able to order them the same way they were specified.

Comments (4)

  1. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.