0

I have made a dataDict after processing some data in my view which i retrieved from models. I want to serialize the dataDict and send it back using HttpResponse.

dataDict = 'cpu='+str(cpu_count)+'&memory='+str(memory_size)+'&count='+str(count)+''
qdict = QueryDict(dataDict)

when i print the qDict it gives the following output.

<QueryDict: {u'count': [u'77'], u'cpu': [u'187'], u'memory': [u'352256']}>

now i want to serialize the qdict and send it back as json data. any idea.

1
  • use the, data = serialize("json", qdict) gives me error AttributeError: 'unicode' object has no attribute '_meta'. Commented Feb 26, 2014 at 6:07

1 Answer 1

1

Standard library has json module to handle such tasks:

import json
json_string = json.dumps(qdict.dict())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.