0
{
    '4': [1, 'Product New', '450.00', '4'], 
    '6': [1, 'Products Hello', '4500.00', '6']
}

I receive data in my view.py:

using products = json.loads(data)

After that, i am trying to show each item's in Django templates. 4 and 6 is pro

3
  • what did you get in your template? Commented Oct 2, 2021 at 11:32
  • i got like this json data in my template but how to parse ?? {'4': [1, 'Product New', '450.00', '4'], '6': [1, 'Products Hello', '4500.00', '6']} Commented Oct 2, 2021 at 11:36
  • You can try my answer, hope it will solve your issue Commented Oct 2, 2021 at 11:36

1 Answer 1

2

You can try this:

data = {
    '4': [1, 'Product New', '450.00', '4'], 
    '6': [1, 'Products Hello', '4500.00', '6']
}

json_string = json.loads(data)
return render(request,'test.html',{'dataset':json_string})

HTML Part:

{% for key, value in dataset.items %}
{{key}}: {{value}}
{% endfor %}
Sign up to request clarification or add additional context in comments.

1 Comment

json_string = json.loads(data) working thank you

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.