I am calling an API that returns JSON data. I am using json.loads to decode the JSON to Python as a dictionary. The dictionary that returns is a somewhat complex nested dictonary with nested lists as well.
For example:
{ "educations": { "_total": 1, "values": [{ "degree": "Bachelor of Arts", "fieldOfStudy": "Psychology", "schoolName": "Antioch University Seattle" }] }
How do I store each of the values into an SQLite database with the model defined as:
class Educations(models.Model):
name = models.ForeignKey(Candidate)
degree = models.CharField(max_length=200)
fieldOfStudy = models.CharField(max_length=200)
schoolName = models.CharField(max_length=200)
Each education is associated with a Candidate which is defined in the Candidate class (not shown here).
You can set the fields in new object like
Note: How you will get the data for the
nameforeignkey is not mention in your question so that also you can set.