本文介绍了Django Rest框架'serializers.DictFields'不再存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我从下面导入序列化程序,并查找所有字段,我看不到 DictField

If I import serializers from below, and look for all the fields, I don't see DictField

>>> from rest_framework import serializers
>>> print("\n".join([foo for foo in dir(serializers) if "Field" in foo]))
BooleanField
BoundField
CharField
ChoiceField
DateField
DateTimeField
DecimalField
DjangoImageField
EmailField
Field
FieldDoesNotExist
FileField
FloatField
HiddenField
HyperlinkedIdentityField
HyperlinkedRelatedField
ImageField
IntegerField
ListField
ManyRelatedField
ModelField
MultipleChoiceField
NestedBoundField
NullBooleanField
PrimaryKeyRelatedField
ReadOnlyField
RegexField
RelatedField
SerializerMethodField
SkipField
SlugField
SlugRelatedField
StringRelatedField
TimeField
URLField

但是它在文档,就在ListField之后(在上面的列表中)。这是否在最新版本的DRF中,或者我在错误的地方看?

But it's in the docs here, just after ListField (which is in the above list). Has this gone in the latest version of DRF, or am I looking in the wrong place?

推荐答案

DictField已添加到。

DictField was added in 3.0.4.

更新!

这篇关于Django Rest框架'serializers.DictFields'不再存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-20 17:35