django - Djongo 支持固定装置吗?
问题描述
我想创建夹具并在测试中使用它们。但是当我尝试通过运行加载它们时./manage.py loaddata test.json
,我得到了DeserializationError
. 追溯:
django.core.serializers.base.DeserializationError: Problem installing fixture
'/app/test.json': Value: OrderedDict() stored in DB must be of type dict/listDid you miss
any Migrations?: (template.template:pk=5) field_value was 'OrderedDict()'
这只是一个示例,但基本上,它会抱怨它遇到的任何 JSON 字符串。所以看起来 test.json 被反序列化了一次,并且 JSONFields 的值被保留为 JSON 字符串。所以它在这里抛出一个错误:
# from Djongo's JSONField class
def to_python(self, value):
if not isinstance(value, (dict, list)):
raise ValueError(
f'Value: {value} stored in DB must be of type dict/list'
'Did you miss any Migrations?'
)
return value
Github上有一个类似的问题被放弃了。所以我不确定在这一点上夹具是否应该与 Djongo 一起使用。
提前感谢您的任何澄清。
解决方案
推荐阅读
- python - 无法读取 x.png,因为文件丢失、权限不正确、格式不受支持或无效
- javascript - 在 Vue 3 中使用 axios 时出现 UncaughtType 错误
- python - from tensorboardX import SummaryWriter 仅第二次有效
- laravel - Laravel Echo Server net::ERR_CONNECTION_TIMED_OUT 仅当我的 ip 不包含在 Firefall 中时 - Centos
- azure - 从 azure devops 管道更新变量组
- javascript - 在firebase函数中发布axios请求
- node.js - 为什么dockerfile中的RUN不处理npx,节点命令
- spring-boot - Apache Camel/Spring 启动禁用跟踪
- android - 在 Flutter 和 iOS 中单击 InkWell 或 GestureDector 不起作用
- 2sxc - 当要更新的实体具有对另一个实体的引用时,App.Data.Update 会引发对象引用错误