Answer the question
In order to leave comments, you need to log in
How to upload json to Django database using loaddata?
I came across a task related to loading data from json into Django db via manage.py loaddata.
The problem is that the data is in this format:
[
{
"id": 1,
"first_name": "Gena",
"last_name": "Bukin",
"email": "[email protected]",
"gender": "Male",
"ip_address": "17.13.19.31"
},
{
"id": 2,
"first_name": "Anton",
"last_name": "Drakon",
"email": "[email protected]",
"gender": "Male",
"ip_address": "15.25.235.175"
}
]
[
{
"model": "myapp.person",
"pk": 1,
"fields": {
"first_name": "John",
"last_name": "Lennon"
}
},
{
"model": "myapp.person",
"pk": 2,
"fields": {
"first_name": "Paul",
"last_name": "McCartney"
}
}
]
Answer the question
In order to leave comments, you need to log in
How about writing a script to convert one JSON format to another and then load it via manage.py loaddata
?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question