1

I am able to load 1 fixture file into the database, but not the 2nd file. I run the command python manage.py loaddata fixture.json, and I get the error. I'm not sure how to solve this serialization error, any insights appreciated.

The error:

    for obj in objects:
  File "/Users/ayunas/.local/share/virtualenvs/CS24-BW-MUD-lJVJyZQx/lib/python3.7/site-packages/django/core/serializers/json.py", line 73, in Deserializer
    raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture '/Users/ayunas/Documents/lambda/CS24-BW-MUD/tower_app/fixtures/test_fixture.json': 

Here is how the fixture file looks like:

[
    {
      "model": "tower_app.item",
      "pk": 1,
      "fields": {
        "item_name": "Black Stone",
        "description": "a white stone from Paradise, blackened by the sins of mankind.",
        "strength": 10,
        "item_type": "weapon",
        "playerID" : null,
        "roomID" : 4
      }
    }
]
Amir
  • 1,422
  • 1
  • 15
  • 28
  • Is it missing the closing square bracket? And does it have an unneeded comma after the last curly bracket? – jcfollower Jan 09 '20 at 16:31
  • @jcfollower, the syntax of the json object is correct. I updated it above – Amir Jan 09 '20 at 16:58
  • Could the issue be that you've hardcoded the pk to 1? – ekneiling Jan 09 '20 at 19:00
  • No, because I have another fixture file where the pk is hard coded, and it works just fine. Here's a snippet from the other fixture json file that loads properly: ```[ { "model": "tower_app.room", "pk": 12, "fields": { "id": 12, "room_name": "Inclement'", "description": "Description for the Inclement' room ", "up": "Optimism'", "down": "", "left": "", "right": "Oakwood'", "floor": 2 } }]``` – Amir Jan 09 '20 at 20:54

0 Answers0