'Django: How to convert indexed QueryDict into array of QueryDicts?

I am handling a POST request and I receive in request.data the following data structure:

<QueryDict: {'document[0]name': ['sample-0.pdf'], 'document[0]folder': ['folder-0'], 'document[1]name': ['sample-1.pdf'], 'document[1]category': ['file'], 'document[1]folder': ['folder-1']}>

How can I convert this to the following data structure:

[<QueryDict: {'name': ['sample-0.pdf'], 'folder': ['folder-0']}>, <QueryDict: {'name': ['sample-1.pdf'], 'category': ['file'], 'folder': ['folder-1']}>]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source