def can_handle_request(self, content_type): """ Returns :const:`True` if this parser is able to deal with the given *content_type*. The default implementation for this function is to check the *content_type* argument against the :attr:`media_type` attribute set on the class to see if they match. This may be overridden to provide for other behavior, but typically you'll instead want to just set the :attr:`media_type` attribute on the class. """ return media_type_matches(self.media_type, content_type)
def can_handle_response(self, accept): """ Returns :const:`True` if this renderer is able to deal with the given *accept* media type. The default implementation for this function is to check the *accept* argument against the :attr:`media_type` attribute set on the class to see if they match. This may be overridden to provide for other behavior, but typically you'll instead want to just set the :attr:`media_type` attribute on the class. """ format = self.view.kwargs.get(self._FORMAT_QUERY_PARAM, None) if format is None: format = self.view.request.GET.get(self._FORMAT_QUERY_PARAM, None) if format is not None: return format == self.format return media_type_matches(self.media_type, accept)