python - How to populate JSON dump from a form to a django template? -


i importing post request form template.html view.py using

data=json.dumps(request.post) 

the data @ view.py in format:

{"5": "25", "4": "28", "6": "21"} 

while running dictionary syntax on it, error pops data in string form. how convert dictionary? further, need populate 'key' , 'value' of dictionary template.

please me out?

try this:

>>> = '{"5": "25", "4": "28", "6": "21"}' >>> type(a) <type 'str'> >>>  >>> import ast >>> x = ast.literal_eval(a) >>> type(x) <type 'dict'> >>>  >>> x.keys() ['5', '4', '6'] >>> x.values() ['25', '28', '21'] 


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -