gpt4 book ai didi

python - 属性错误 : module 'django.contrib.postgres.fields' has no attribute 'JSONField'

转载 作者:行者123 更新时间:2023-11-29 14:34:44 25 4
gpt4 key购买 nike

从 GitHub 仓库安装项目并最终收到以下错误

 File "/Users/TheKotik/closer/blog/models.py", line 5, in <module>
from rest_framework import serializers
File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/rest_framework/serializers.py", line 1534, in <module>
ModelSerializer.serializer_field_mapping[postgres_fields.JSONField] = JSONField
AttributeError: module 'django.contrib.postgres.fields' has no attribute 'JSONField'

不知道它与什么有关。请帮助..

整个回溯:

    File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Users/TheKotik/closer/blog/models.py", line 5, in <module>
from rest_framework import serializers
File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/rest_framework/serializers.py", line 1534, in <module>
ModelSerializer.serializer_field_mapping[postgres_fields.JSONField] = JSONField
AttributeError: module 'django.contrib.postgres.fields' has no attribute 'JSONField'

最佳答案

您的 Django 版本太低。 JSONField 是在 Django 1.9 ( release notes ) 中添加的,因此您需要升级才能使用 JSONField

关于python - 属性错误 : module 'django.contrib.postgres.fields' has no attribute 'JSONField' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46915614/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com