[英]simplejson error with Django 1.8.2 and dumpdata
命令:
% ./manage.py dumpdata
輸出:
CommandError: Unable to serialize database: cannot import name simplejson
zc.buildout配置為在app目錄中安裝simplejson。 我的自定義Python目錄/ usr / local / python中也存在simplejson。
謝謝你的幫助!
堆棧跟蹤:
% ./manage.py dumpdata --traceback
Traceback (most recent call last):
File "./manage.py", line 25, in <module>
sys.exit(djangorecipe.manage.main('project.settings.settings_dev'))
File "/opt/project/eggs/djangorecipe-1.11-py2.7.egg/djangorecipe/manage.py", line 9, in main
management.execute_from_command_line(sys.argv)
File "/opt/project/eggs/Django-1.8.2-py2.7.egg/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/opt/project/eggs/Django-1.8.2-py2.7.egg/django/core/management/__init__.py", line 330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/project/eggs/Django-1.8.2-py2.7.egg/django/core/management/base.py", line 390, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/project/eggs/Django-1.8.2-py2.7.egg/django/core/management/base.py", line 441, in execute
output = self.handle(*args, **options)
File "/opt/project/eggs/Django-1.8.2-py2.7.egg/django/core/management/commands/dumpdata.py", line 162, in handle
stream=stream or self.stdout)
File "/opt/project/eggs/Django-1.8.2-py2.7.egg/django/core/serializers/__init__.py", line 128, in serialize
s = get_serializer(format)()
File "/opt/project/eggs/Django-1.8.2-py2.7.egg/django/core/serializers/__init__.py", line 51, in __call__
raise self.exception
ImportError: cannot import name simplejson
django.utils.simplejson
,不要與混淆simplejson模塊被棄用在Django 1.7,我們現在依靠內置蟒JSON。 如果您正在運行舊版第三方代碼,或某些難以更改的代碼,請執行此操作
try:
import django.utils.simplejson
except:
import json as simplejson
如果要編寫新代碼,請編寫此代碼以實現向后兼容:
try:
import json
except:
import django.utils.simplejson as json
在您的情況下,是manage.py引發錯誤,還是該錯誤在代碼中的其他地方? 您可以發布stacktrace嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.