Django Rest Framework does 'serializers.DictFi

2019-09-15 05:12发布

问题:

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

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?

回答1:

DictField was added in 3.0.4.

UPDATE!