Determine and return a 'formats.Format' instance describing the most desired response format
        that is supported by these views.

        :param request: A django.http.HttpRequest instance.

        Formats specified by extension (e.g. '/articles/index.html') take precedence over formats
        given in the HTTP Accept header, even if it's a format that isn't known by Respite.

        If the request doesn't specify a format by extension (e.g. '/articles/' or '/articles/new')
        and none of the formats in the HTTP Accept header are supported, Respite will fall back
        on the format given in DEFAULT_FORMAT.

def _get_format(self, request):
        """
        Determine and return a 'formats.Format' instance describing the most desired response format
        that is supported by these views.

        :param request: A django.http.HttpRequest instance.

        Formats specified by extension (e.g. '/articles/index.html') take precedence over formats
        given in the HTTP Accept header, even if it's a format that isn't known by Respite.

        If the request doesn't specify a format by extension (e.g. '/articles/' or '/articles/new')
        and none of the formats in the HTTP Accept header are supported, Respite will fall back
        on the format given in DEFAULT_FORMAT.
        """

        # Derive a list of 'formats.Format' instances from the list of formats these views support.
        supported_formats = [formats.find(format) for format in self.supported_formats]

        # Determine format by extension...
        if '.' in request.path:
            extension = request.path.split('.')[-1]

            try:
                format = formats.find_by_extension(extension)
            except formats.UnknownFormat:
                return None

            if format in supported_formats:
                return format
            else:
                return None

        # Determine format by HTTP Accept header...
        if 'HTTP_ACCEPT' in request.META:
            content_types = parse_http_accept_header(request.META['HTTP_ACCEPT'])

            # Only consider 'accept' headers with a single format in an attempt to play nice
            # with browsers that ask for formats they really should not want.
            if len(content_types) == 1:
                content_type = content_types[0]

                # If the request has no preference as to the format of its response, prefer the
                # first of the view's supported formats.
                if content_type == '*/*':
                    return supported_formats[0]

                try:
                    format = formats.find_by_content_type(content_type)
                except formats.UnknownFormat:
                    return None

                if format in supported_formats:
                    return format
                else:
                    return None

        # If no format is given by either extension or header, default to the format given in
        # RESPITE_DEFAULT_FORMAT (given, of course, that it's supported by the view).
        if DEFAULT_FORMAT:
            format = formats.find(DEFAULT_FORMAT)

            if format in supported_formats:
                return format
            else:
                return None