rest_framework.utils.field_mapping

Helper functions for mapping model fields to a dictionary of default keyword arguments that should be used for their equivalent serializer fields.

Module Contents

NUMERIC_FIELD_TYPES
class ClassLookupDict(mapping)

Bases:object

Takes a dictionary with classes as keys. Lookups against this object will traverses the object’s inheritance hierarchy in method resolution order, and returns the first matching value from the dictionary or raises a KeyError if nothing matches.

__getitem__(self, key)
__setitem__(self, key, value)
needs_label(model_field, field_name)

Returns True if the label based on the model’s verbose name is not equal to the default label it would have based on it’s field name.

get_detail_view_name(model)

Given a model class, return the view name to use for URL relationships that refer to instances of the model.

get_field_kwargs(field_name, model_field)

Creates a default instance of a basic non-relational field.

get_relation_kwargs(field_name, relation_info)

Creates a default instance of a flat relational field.

get_nested_relation_kwargs(relation_info)
get_url_kwargs(model_field)