def extract_json_mask_from_request(request): includes, excludes = {}, {} excludes_name = getattr(settings, 'REST_FRAMEWORK_JSONMASK_EXCLUDES_NAME', constants.EXCLUDES_NAME) fields_name = getattr(settings, 'REST_FRAMEWORK_JSONMASK_FIELDS_NAME', constants.FIELDS_NAME) if fields_name in request.GET: includes = parse_fields(request.GET[fields_name]) if excludes_name in request.GET: excludes = parse_fields(request.GET[excludes_name]) if includes and excludes: raise ValueError('Cannot supply both `%s` and `%s`' % ( fields_name, excludes_name, )) return includes, excludes
def excluded_fields(self): excludes_name = getattr(settings, 'REST_FRAMEWORK_JSONMASK_EXCLUDES_NAME', constants.EXCLUDES_NAME) return parse_fields(self.request.GET.get(excludes_name))
def requested_fields(self): fields_name = getattr(settings, 'REST_FRAMEWORK_JSONMASK_FIELDS_NAME', constants.FIELDS_NAME) return parse_fields(self.request.GET.get(fields_name))