[ { "description": "A cowboy doll is profoundly threatened and jealous when a new spaceman figure supplants him as top toy in a boy's room.", "genre": "Animation,Adventure,Comedy,Family,Fantasy", "imdb_url": "https://www.imdb.com/title/tt0114709/", "img_url": "https://m.media-amazon.com/images/M/MV5BMDU2ZWJlMjktMTRhMy00ZTA5LWEzNDgtYmNmZTEwZTViZWJkXkEyXkFqcGdeQXVyNDQ2OTk4MzI@._V1_UX182_CR0,0,182,268_AL__QL50.jpg", "movie_id": 114709, "title": "Toy Story", "users_rating": 8.3, "year": 1995 }, { "description": "George Banks must deal not only with the pregnancy of his daughter, but also with the unexpected pregnancy of his wife.", "genre": "Comedy,Family,Romance", "imdb_url": "https://www.imdb.com/title/tt0113041/", "img_url": "https://m.media-amazon.com/images/M/MV5BOTEyNzg5NjYtNDU4OS00MWYxLWJhMTItYWU4NTkyNDBmM2Y0XkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_UX182_CR0,0,182,268_AL__QL50.jpg", "movie_id": 113041, "title": "Father of the Bride Part II", "users_rating": 6, "year": 1995 }]
3 Réponses :
Les fichiers de fixtures doivent correspondre au format de sérialisation a >, par exemple: Vous devez donc réécrire vos appareils de la manière suivante: [
{
"pk": "4b678b301dfd8a4e0dad910de3ae245b",
"model": "sessions.session",
"fields": {
"expire_date": "2013-01-16T08:16:59.844Z",
...
}
}
]
modèle
pk
champs
objet interne
Comment puis-je convertir mon fichier json au format de sérialisation?
Soit ajouter manuellement les champs obligatoires, soit écrire le programme à convertir
Parfois, les objets ne sont pas fermés correctement
J'avais des instructions d'impression dans manage.py. Cette sortie était enregistrée dans le fichier json de l'appareil qui générait une erreur de format. La suppression de ces instructions d'impression l'a résolu. Voici mon ancien fichier .json (mauvais format). J'ai supprimé la première ligne et cela a fonctionné.
app.yaml file = dev_app.yaml [ { "model": "plans.planslevel1", "pk": 1, "fields": { "name": "abc", "description": "xyz" } }]