rest_witchcraft.fields module¶
Some SQLAlchemy specific field types.
-
class
rest_witchcraft.fields.
CharMappingField
(**kwargs)[source]¶ Bases:
rest_framework.fields.DictField
Used for Postgresql HSTORE columns for storing key-value pairs.
-
child
= CharField(allow_null=True)¶
-
-
class
rest_witchcraft.fields.
HyperlinkedIdentityField
(view_name=None, **kwargs)[source]¶ Bases:
rest_framework.relations.HyperlinkedIdentityField
-
class
rest_witchcraft.fields.
ImplicitExpandableListField
(**kwargs)[source]¶ Bases:
rest_framework.fields.ListField
List field which implicitly expands parent field when child field is expanded assuming parent field is also expandable by being one of the choices.
-
class
rest_witchcraft.fields.
SkippableField
(*, read_only=False, write_only=False, required=None, default=<class 'rest_framework.fields.empty'>, initial=<class 'rest_framework.fields.empty'>, source=None, label=None, help_text=None, style=None, error_messages=None, validators=None, allow_null=False)[source]¶ Bases:
rest_framework.fields.Field
Field which is always skipped on to_representation.
Useful when used together with
ExpandableModelSerializer
since it allows to completely skip expandable field when it is not being expanded. Especially useful forOneToMany
relations since by default nested serializer cannot be rendered as none of the PKs of the “many” items are known unlikeManyToOne
when nested serializer can be rendered with PK. For example:class FooSerializer(ExpandableModelSerializer): bar = BarSerializer(many=True) class Meta: model = Foo session = session fields = "__all__" expandable_fields = { "bar": SkippableField() }
-
class
rest_witchcraft.fields.
UriField
(view_name=None, **kwargs)[source]¶ Bases:
rest_witchcraft.fields.HyperlinkedIdentityField
Represents a uri to the resource.