在服务器(加载数据)上添加夹具时出现反序列化错误

DeserializationError when adding fixture on server (loaddata)

我正在尝试将我的数据添加到服务器的数据库中。我在我的本地机器上使用完全相同的 JSON 文件并且它可以工作。但是当我在服务器上做同样的事情时,它给了我 Deserialization Error.

JSON文件太大,我不能在这里显示,但我确定没有错字。

我完成了所有迁移和数据库工作 - 我可以从管理仪表板添加对象。我该如何解决这个错误?

我得到的错误:

    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': 

检查了一遍又一遍JSON,但它仍然在本地工作,但在服务器上出现同样的错误。

我在服务器上使用 Ubuntu。并且没有安装 git-lfs。解决这个问题:

  1. sudo apt-get install git-lfs安装。

  2. 然后 运行 git lfs pull 在项目目录下。

然后我设法根据需要处理 JSON 数据。