In the project there is a model with existing instances in the database.
class Instagram(models.Model):
userid = models.CharField(max_length=255, unique=True)
username = models.CharField(max_length=50, blank=True, null=True)
full_name = models.CharField(max_length=50, blank=True, null=True)
avatar = models.URLField(max_length=255, blank=True, null=True)
bio = models.CharField(max_length=255, blank=True, null=True)
.....
.....
There is another model, so far without instaces
class InstagramDemographicsAnalitics(models.Model):
instagram = models.ForeignKey(Instagram, related_name='demographics')
age_group = models.CharField(max_length=10)
gender = models.CharField(max_length=10, default='female')
viewer_percentage = models.DecimalField(default=0, max_digits=5, decimal_places=2)
It is necessary from the file statistic.json, which is in the same folder with the project, to take the data for the corresponding userid and on their basis create the instances of the model InstagramDemographicsAnalitics.
I have no idea how to do this. I really need advice with a sequence of actions and if possible code example.
JSONobject(s)?