rest_framework.utils.model_meta

Helper function for returning the field information that is associated with a model class. This includes returning all the forward and reverse relationships and their associated metadata.

Usage: get_field_info(model) returns a FieldInfo instance.

Module Contents

FieldInfo
RelationInfo
get_field_info(model)

Given a model class, returns a FieldInfo instance, which is a namedtuple, containing metadata about the various field types on the model including information about their relationships.

_get_pk(opts)
_get_fields(opts)
_get_to_field(field)
_get_forward_relationships(opts)

Returns an OrderedDict of field names to RelationInfo.

_get_reverse_relationships(opts)

Returns an OrderedDict of field names to RelationInfo.

_merge_fields_and_pk(pk, fields)
_merge_relationships(forward_relations, reverse_relations)
is_abstract_model(model)

Given a model class, returns a boolean True if it is abstract and False if it is not.