I have a GET
query the format is like this:
?title1=a&test1=b&title2=a&test2=b&..&titleN=a&testN=b
The view contains just the code above
def index(request):
# This is my view
print request.GET.items():
This is the result returned I got from the view when I run the query :
{ 'title1':'a', 'test1':'b', 'title2':'a', 'test2':'b','titleN':'a', 'testN':'b' }
I want to create a new list of dictionary.
[
{
'title1' : 'a' ,
'test1':'b'
},
{
'title2' : 'a' ,
'test2':'b'
},
{
'titleN' : 'a',
'testN':'b'
}
]
As you can notice I want to arrange all the data by number and N here is a Number
The question is how to make a list like I mentioned above , the only convention is the dictionary contains keys with the same last number .
And then I want the list become like this :
[
{
'title' : 'a' ,
'test':'b'
},
{
'title' : 'a' ,
'test':'b'
},
{
'title' : 'a',
'test':'b'
}
]