@classmethod<EOL><INDENT>def add_relationship(_class, name,<EOL>view_name=None, lookup_field=None,<EOL>serializer=None, many=False, queryset=None,<EOL>function=None):<DEDENT>
if view_name is not None and lookup_field is not None:<EOL><INDENT>_class._relationships[name] = {<EOL>'<STR_LIT:type>': '<STR_LIT>',<EOL>'<STR_LIT>': view_name,<EOL>'<STR_LIT>': lookup_field<EOL>}<EOL><DEDENT>elif serializer is not None and queryset is not None:<EOL><INDENT>_class._relationships[name] = {<EOL>'<STR_LIT:type>': '<STR_LIT>',<EOL>'<STR_LIT>': serializer,<EOL>'<STR_LIT>': many,<EOL>'<STR_LIT>': queryset<EOL>}<EOL><DEDENT>elif function is not None:<EOL><INDENT>_class._relationships[name] = {<EOL>'<STR_LIT:type>': '<STR_LIT>',<EOL>'<STR_LIT>': function<EOL>}<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>
adds a relationship to serializer
        :param name: relationship name (dictionary key)
        :type name: str
        :param view_name: view name as specified in urls.py
        :type view_name: str
        :param lookup_field: lookup field, usually slug or id/pk
        :type lookup_field: str
        :param serializer: Serializer class to use for relationship
        :type serializer: Serializer
        :param many: indicates if it's a list or a single element, defaults to False
        :type many: bool
        :param queryset: queryset string representation to use for the serializer
        :type queryset: QuerySet
        :param function: function that returns the value to display (dict, list or str)
        :type function: function(obj, request)
        :returns: None