I'm working on a Django project using a noSQL database MongoDB. I have the data I need to populate the database with stored in a JSON file, but I can't figure out how to do it. The model, which I'm trying to have a one to many relationship with other objects of the same class:
class Hero(models.Model):
name = models.TextField(max_length=120, null=True)
counters = models.ForeignKey('self', null=True, on_delete=models.CASCADE)
image = models.ImageField(blank=False, null=True, upload_to="")
And the example of my JSON file data:
{
"Abaddon":{
"counters":[
"Ancient Apparition",
"Brewmaster",
"Doom",
"Outworld Devourer",
"Shadow Demon"
],
"image":"media/Abaddon.png"
},...
Do I need to format the JSON data differently? I'm at a loss here.