def get_field_defs(form, is_formset = True): ''' Genera la definición del JSON para el diccionario @param form: Formulario @param is_formset: Indica si es un formset ''' fields = [] initial = getattr(form, 'initial') or {} prefix = getattr(form, 'prefix') or u'' for name, field in form.fields.iteritems(): # Si tiene prefijo d = {} if initial.has_key(name): d['value'] = initial.get(name) if field.initial is not None: d['value'] = field.initial if field.help_text: d['toolTip'] = field.help_text name = prefix and "%s-%s" % (prefix, name) or name d.update(field_dumper.dump(field, is_formset), name = name) fields.append(d) return fields
def field_instances(self): fields = list(self.meta.fields) for field in self.dynamic_fields: fields.append( Field(name=field, verbose_name=field.replace('_', ' '), editable=False)) return fields
def get_filter_fields(model): """ Return a list of all filterable fields of Model. -Takes: Model type -Returns: A list of fields as string (excluding ID and file uploading) """ model_fields = model._meta.get_fields() fields = [] for field in model_fields: res = str(field).split('.') if res[1] == model.__name__ and not isinstance(field, (AutoField, FileField)): fields.append(field.name) return fields
def build_search_fields(self): import django.db.models.fields fields = [ ] IGNORE_TYPES = set([ django.db.models.fields.AutoField, django.db.models.fields.related.ForeignKey, django.db.models.fields.related.ManyToManyField, ]) IGNORE_NAMES = set([ "ver", "comment", "features", "created", ]) for f in SystemVersion._meta.get_fields(): if not type(f) in IGNORE_TYPES and \ not f.name in IGNORE_NAMES: fields.append(f.name) ## FOR return (sorted(fields))
def build_search_fields(self): import django.db.models.fields fields = [] IGNORE_TYPES = set([ django.db.models.fields.AutoField, django.db.models.fields.related.ForeignKey, django.db.models.fields.related.ManyToManyField, ]) IGNORE_NAMES = set([ "ver", "comment", "features", "created", ]) for f in SystemVersion._meta.get_fields(): if not type(f) in IGNORE_TYPES and \ not f.name in IGNORE_NAMES: fields.append(f.name) ## FOR return (sorted(fields))
def system_field_instances(self): fields = [] for field in self.field_instances: if not field.editable: fields.append(field) return fields