Answer the question
In order to leave comments, you need to log in
How to work with json in Python?
There is a table of users, in it the standard data on users.
The likes column contains json likes in the format [{"likes":"one"},{"likes":"two"}].
When receiving information about a user, data with likes is sent to the template in string format.
You need to present the data in a formatted form. so this line doesn't work.
How to work with data in this case?
Now I'm thinking about writing a separate request for getting characteristics (likes), transferring the received to json (dict as an option) on the controller and giving it to the template separately?
Maybe there are other options?
Answer the question
In order to leave comments, you need to log in
import json
d = json.loads('[{"likes":"one"},{"likes":"two"}]')
print(d[0]["likes"])
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question