Returns the valid choices for ``field``.  The ``field_name`` argument is given for
        convenience.
494137
def get_field_choices(self, field, field_name):
        
        if self.request.GET.get('select2'):
            names = ['id', 'text']
        else:
            names = ['value', 'text']
        choices_getter = getattr(self, 'get_field_%s_choices', None)
        if choices_getter is None:
            if isinstance(field, ForeignKey):
                choices_getter = self._get_foreignkey_choices
            else:
                choices_getter = self._get_default_choices
        return [dict(zip(names, choice)) for choice in choices_getter(field, field_name)]
864412
def get_field_list(fields, schema):
  
  # If the fields weren't supplied get them from the schema.
  if schema:
    all_fields = [f['name'] for f in schema._bq_schema if f['type'] != 'RECORD']

  if isinstance(fields, list):
    if schema:
      # validate fields exist
      for f in fields:
        if f not in all_fields:
          raise Exception('Cannot find field %s in given schema' % f)
    return fields
  if isinstance(fields, basestring) and fields != '*':
    if schema:
      # validate fields exist
      for f in fields.split(','):
        if f not in all_fields:
          raise Exception('Cannot find field %s in given schema' % f)
      return fields.split(',')
  if not schema:
    return []
  return all_fields
977439
def validate_field(self, value):
        '''
        
        '''
        if self.choices:
            value = self.normalize_field(value)
            if value in self.choices:
                return None
            return _('Must be one of: %(choices)s') % {'choices': '; '.join(self.choices)}
        if self.default is not None:
            if value is None or value == '':
                value = self.default
        if self.required and (value is None or value == ''):
            return _('Required field')
943334
def multiple_choice(name, choices = [], options = {})
      field name, MultipleChoiceField.new(choices, options)
    end
1210513
def get_field_name(self, field):
        
        for field_name, f in self.fields.items():
            if f == field:
                return field_name
        raise AttributeError("Field %s does not exists in %s resource" % (
            field, self.__class__))
1049379
def choices(self, cl):
        
        #: Just tidy up standard implementation for the sake of DRY principle.
        def _choice_item(is_selected, query_string, title):
            return {
                'selected': is_selected,
                'query_string': query_string,
                'display': force_text(title),
            }

        yield _choice_item(
            self.lookup_val is None,
            cl.get_query_string({}, [self.lookup_kwarg]),
            _('All'))

        container = (self.field.choices
                     if isinstance(self.field, ChoicesField) else
                     self.field.flatchoices)

        for lookup, title in container:
            yield _choice_item(
                smart_text(lookup) == self.lookup_val,
                cl.get_query_string({self.lookup_kwarg: lookup}),
                title)
749461
def p_field_optional2_4(self, p):
        
        p[0] = Field(name=p[2], alias=p[1], selections=p[3])
723201
def in_field(self, field_name, *field_vals, **field_kwargs):
        
        field_name = self._normalize_field_name(field_name)
        fv = make_list(field_vals[0]) if field_vals else None
        if field_kwargs:
            for k in field_kwargs:
                if not field_kwargs[k]:
                    raise ValueError("Cannot IN an empty list")

                field_kwargs[k] = make_list(field_kwargs[k])

        else:
            if not fv: self.can_get = False

        self.fields_where.append(field_name, ["in", field_name, fv, field_kwargs])
        return self
437949
def get_field_by_name(self, name):
        

        for f in self.fields:
            if f.get_name() == name:
                return f
        return None
1358526
def get_field(self, name):
        
        # Quicker in case the exact name was used.
        field = self._all_fields.get(name)
        if field is not None:
            return field

        for field_name, field in self._all_fields.items():
            if self._sanitize_field_name(name) == self._sanitize_field_name(field_name):
                return field
875325
def get_values(self, field_name: str) -> List[object]:
        
        result = list()
        if self.validate_field(field_name):
            for value_key in self._kg.get(field_name):
                result.append(value_key["value"])
        return result
1055792
def get_field_info(self, field):
        
        field_info = collections.OrderedDict()
        field_info['type'] = self.label_lookup[field]
        field_info['required'] = getattr(field, 'required', False)

        attrs = [
            'read_only', 'label', 'help_text', 'allow_null',
            'min_length', 'max_length',
            'min_value', 'max_value',
        ]

        # Handle default attribute
        default_value = getattr(field, 'default')
        if (default_value is not empty):
            field_info['default'] = force_text(
                default_value, strings_only=True)

        for attr in attrs:
            value = getattr(field, attr, None)
            if value is not None and value != '':
                field_info[attr] = force_text(value, strings_only=True)

        if hasattr(field, 'choices'):
            field_info['choices'] = [
                {
                    'value': choice_value,
                    'display_name': force_text(choice_name, strings_only=True)
                }
                for choice_value, choice_name in field.choices.items()
            ]

        # handle RegexField
        if isinstance(field, serializers.RegexField):
            pattern = None
            for validator in field.validators:
                if isinstance(validator, RegexValidator):
                    pattern = validator.regex.pattern
                    break
            field_info['pattern'] = force_text(pattern, strings_only=True)

        # handle DecimalField
        if isinstance(field, serializers.DecimalField):
            for attr in ('max_digits', 'decimal_places'):
                field_info[attr] = force_text(
                    getattr(field, attr), strings_only=True)

        return field_info
1276951
def get_displayable_field_names(self):
        
        return [
            f.name
            for f in self.model._meta.get_fields()
            if not f.one_to_many
        ]
1311573
def get_placeholder_field_names(self):
        
        return [field.name for field in self._meta.fields if field.get_internal_type() == 'PlaceholderField']
1121730
def field_(self, name):
    
    try:
        field = self.fields[name]
    except KeyError:
        raise KeyError("Key %r not found in '%s'" % (name, self.__class__.__name__))
    return BoundField(self, field, name)
799607
def get_verbose_field_name(instance, field_name):
    
    fields = [field.name for field in instance._meta.fields]
    if field_name in fields:
        return instance._meta.get_field(field_name).verbose_name
    else:
        return field_name
770713
def check_field_exists(self, field_name):
        
        if not settings.DEBUG:
            return

        try:
            self.lookup_opts.get_field(field_name)

        except FieldDoesNotExist as e:
            raise AdmirarchyConfigurationError(e)