djangodjango-modelsdjango-fixtures

DeserializationError when adding fixture on server (loaddata)


I am trying to add my data to database in my server. I use exactly the same JSON file in my local machine and it works. But when I do the same in server it gives me Deserialization Error.

The JSON file is so big that I can't show it here but I am sure there is no typo.

I did all migrations and database works - I can add object from admin dashboard. How can I solve this error?

The error I get:

    Traceback (most recent call last):
  File "/home/testuser/myprojectt/myvenv/lib/python3.8/site-packages/django/core/serializers/json.py", line 69, in Deserializer
    objects = json.loads(stream_or_string)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    main()
  File "manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/testuser/myprojectt/myvenv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/testuser/myprojectt/myvenv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/testuser/myprojectt/myvenv/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/testuser/myprojectt/myvenv/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/home/testuser/myprojectt/myvenv/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 72, in handle
    self.loaddata(fixture_labels)
  File "/home/testuser/myprojectt/myvenv/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 114, in loaddata
    self.load_label(fixture_label)
  File "/home/testuser/myprojectt/myvenv/lib/python3.8/site-packages/django/core/management/commands/loaddata.py", line 172, in load_label
    for obj in objects:
  File "/home/testuser/myprojectt/myvenv/lib/python3.8/site-packages/django/core/serializers/json.py", line 74, in Deserializer
    raise DeserializationError() from exc
django.core.serializers.base.DeserializationError: Problem installing fixture '/home/testuser/myprojectt/myprojectt/articles/fixtures/article.json': 

Checked the JSON again and again but it still working on local but the same error on server.


Solution

  • I am using Ubuntu on the server. And didn't have git-lfs installed. To solve this issue:

    1. Install it with sudo apt-get install git-lfs.

    2. Then run git lfs pull on project directory.

    And then I managed to work with the JSON data as I wanted.