Ejemplo n.º 1
0
    def _nested_field_list(self, f, fl, *name):
        """Get Nested Fields"""
        required_nested_model = f.raw_attributes.get('required')
        if required_nested_model is None or required_nested_model is False:
            ignore_required = True
        else:
            ignore_required = False
        nested_field_list = {}
        for n_f in f.nested_model._meta.field_list.values():
            if isinstance(n_f, NestedModel):
                n = (*name, n_f.name)
                self._nested_field_list(n_f, nested_field_list, *n)
            else:
                nv = None
                if utils.get_nested(self.query, *name) is not None:
                    nv = utils.get_nested(self.query, *name).get(n_f.name)

                nfv = n_f.get_value(nv, ignore_required)
                if f.nested_model._meta.ignore_none_field:
                    if nfv is not None:
                        nested_field_list[n_f.db_column_name] = nfv
                else:
                    nested_field_list[n_f.db_column_name] = nfv

        fl[f.db_column_name] = nested_field_list
Ejemplo n.º 2
0
 def _nested_field_list(self, f, fl, *name):
     """Get Nested Fields"""
     nested_field_list = {}
     for n_f in f.nested_model._meta.field_list.values():
         if isinstance(n_f, NestedModel):
             n = (*name, n_f.name)
             self._nested_field_list(n_f, nested_field_list, *n)
         else:
             nested_field_list[n_f.db_column_name] = n_f.get_value(
                 utils.get_nested(self.query, *name).get(n_f.name),
                 ignore_required=True)
     fl[f.db_column_name] = nested_field_list