所以在我将数据库从sqlite更改为postgresql之前,我执行了python manage.py dumpdata > datadump.json
,在我的app目录中保存了datadump.json
文件和dumpdata.json
文件。:
要在我的新数据库中检索此数据,我执行了python manage.py loaddata datadump.json
,但它返回了此错误:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/management/commands/loaddata.py", line 69, in handle
self.loaddata(fixture_labels)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/management/commands/loaddata.py", line 109, in loaddata
self.load_label(fixture_label)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/management/commands/loaddata.py", line 166, in load_label
for obj in objects:
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/serializers/json.py", line 88, in Deserializer
six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2])
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Users/zorgan/Desktop/postr1/lib/python3.5/site-packages/django/core/serializers/json.py", line 81, in Deserializer
objects = json.loads(stream_or_string)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/__init__.py", line 319, in loads
return _default_decoder.decode(s)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
django.core.serializers.base.DeserializationError: Problem installing fixture '/Users/zorgan/Desktop/project/app/datadump.json': Expecting value: line 2 column 1 (char 1)
知道问题是什么吗?
来自datadump.json
的摘录:
[{"model": "polls.question", "pk": 1, "fields": {"question_text": "What's your name?", "date": "2018-04-02T03:22:20.190", "radio": true...