rest_framework_json_api.utils module

rest_framework_json_api.utils.get_resource_name(context, expand_polymorphic_types=False)

Return the name of a resource.

rest_framework_json_api.utils.get_serializer_fields(serializer)
rest_framework_json_api.utils.format_field_names(obj, format_type=None)

Takes a dict and returns it with formatted keys as set in format_type or JSON_API_FORMAT_FIELD_NAMES

Format_type:

Either ‘dasherize’, ‘camelize’, ‘capitalize’ or ‘underscore’

rest_framework_json_api.utils.undo_format_field_names(obj)

Takes a dict and undo format field names to underscore which is the Python convention but only in case JSON_API_FORMAT_FIELD_NAMES is actually configured.

rest_framework_json_api.utils.format_field_name(field_name)

Takes a field name and returns it with formatted keys as set in JSON_API_FORMAT_FIELD_NAMES

rest_framework_json_api.utils.undo_format_field_name(field_name)

Takes a string and undos format field name to underscore which is the Python convention but only in case JSON_API_FORMAT_FIELD_NAMES is actually configured.

Takes a string value and returns it with formatted keys as set in format_type or JSON_API_FORMAT_RELATED_LINKS.

Format_type:

Either ‘dasherize’, ‘camelize’, ‘capitalize’ or ‘underscore’

Takes a link segment and undos format link segment to underscore which is the Python convention but only in case JSON_API_FORMAT_RELATED_LINKS is actually configured.

rest_framework_json_api.utils.format_value(value, format_type)
rest_framework_json_api.utils.format_resource_type(value, format_type=None, pluralize=None)
rest_framework_json_api.utils.get_resource_type_from_model(model)
rest_framework_json_api.utils.get_resource_type_from_queryset(qs)
rest_framework_json_api.utils.get_resource_type_from_instance(instance)
rest_framework_json_api.utils.get_resource_type_from_manager(manager)
rest_framework_json_api.utils.get_resource_type_from_serializer(serializer)
rest_framework_json_api.utils.get_resource_id(resource_instance, resource)

Returns the resource identifier for a given instance (id takes priority over pk).

rest_framework_json_api.utils.get_included_resources(request, serializer=None)

Build a list of included resources.

rest_framework_json_api.utils.get_default_included_resources_from_serializer(serializer)
rest_framework_json_api.utils.get_relation_instance(resource_instance, source, serializer)
rest_framework_json_api.utils.is_relationship_field(field)

Bases: str

A string like object that additionally has an associated name. We use this for hyperlinked URLs that may render as a named link in some contexts, or render as a plain URL in others.

Comes from Django REST framework 3.2 https://github.com/tomchristie/django-rest-framework

rest_framework_json_api.utils.format_drf_errors(response, context, exc)
rest_framework_json_api.utils.format_error_object(message, pointer, response)
rest_framework_json_api.utils.format_errors(data)