Create related field from `_embed` arguments.
180651
def _create_related(args):
        # type: (Dict) -> None
        """"""
        if '_embed' in request.args:
            embeds = request.args.getlist('_embed')

            args['related'] = ','.join(embeds)

            del args['_embed']
666491
def create_by_natural_key(self, *args):
        

        kwargs = self.natural_key_kwargs(*args)
        for name, rel_to in self.model.get_natural_key_info():
            if not rel_to:
                continue
            nested_key = extract_nested_key(kwargs, rel_to, name)
            # Automatically create any related objects as needed
            if nested_key:
                kwargs[name], is_new = (
                    rel_to.objects.get_or_create_by_natural_key(*nested_key)
                )
            else:
                kwargs[name] = None
        return self.create(**kwargs)
1182336
def _embed_state(embedding, state):
    """"""
    return {u: state[v] for v, chain in embedding.items() for u in chain}
295822
def create_subfield_layer(aspect, ip):
    ''''''
    layer = []
    if 'PANTS' in aspect:
        layer = pgnreader.parse_pagan_file(FILE_SUBFIELD, ip, invert=False, sym=True)
    else:
        layer = pgnreader.parse_pagan_file(FILE_MIN_SUBFIELD, ip, invert=False, sym=True)

    return layer
528904
def related_categories_from_relatable_category(id, related_attribute, params = {})
      api_call(:get, "/relatable_categories/#{id}/related_categories", params.merge!(:related_attribute => related_attribute)) do |response|
        response["related_categories"]
      end
    end
832983
def _m2m_field_data(field, obj):
    
    data = _basic_field_data(field, obj)
    data[Field.TYPE] = FieldType.M2M
    related = field.rel.to
    relation_info = {
        Field.REL_DB_TABLE: related._meta.db_table,
        Field.REL_APP: related._meta.app_label,
        Field.REL_MODEL: related.__name__
    }
    data[Field.REL] = relation_info
    value = data[Field.VALUE]
    value = [x[0] for x in value.values_list('pk')]
    data[Field.VALUE] = value
    return data
379693
def get_model_at_related_field(model, attr):
    

    field = model._meta.get_field(attr)

    if hasattr(field, 'related_model'):
        return field.related_model

    raise ValueError("{model}.{attr} ({klass}) is not a relationship field.".format(**{
        'model': model.__name__,
        'attr': attr,
        'klass': field.__class__.__name__,
    }))
892383
private void processEmbeddedField(Field field) {
    // First create EmbeddedField so we can maintain the path/depth of the
    // embedded field
    EmbeddedField embeddedField = new EmbeddedField(field);
    // Introspect the embedded field.
    EmbeddedMetadata embeddedMetadata = EmbeddedIntrospector.introspect(embeddedField,
        entityMetadata);
    entityMetadata.putEmbeddedMetadata(embeddedMetadata);
  }
936344
private function createEmbed(EmbeddedPropMetadata $embeddedPropMeta, Embed $embed)
    {
        $embedMeta = $embeddedPropMeta->embedMeta;

        $obj = [];
        foreach ($embedMeta->getAttributes() as $key => $attrMeta) {
            $value = $this->getAttributeDbValue($attrMeta, $embed->get($key));
            if (null === $value) {
                continue;
            }
            $obj[$key] = $value;
        }
        foreach ($embedMeta->getEmbeds() as $key => $propMeta) {
            $value = (true === $propMeta->isOne()) ? $this->getEmbedOneDbValue($propMeta, $embed->get($key)) : $this->getEmbedManyDbValue($propMeta, $embed->get($key));
            if (null === $value) {
                continue;
            }
            $obj[$key] = $value;
        }
        return $obj;
    }
586814
def include(self, *fields, **kwargs):
        
        clone = self._clone()

        # Preserve the stickiness of related querysets
        # NOTE: by default _clone will clear this attribute
        # .include does not modify the actual query, so we
        # should not clear `filter_is_sticky`
        if self.query.filter_is_sticky:
            clone.query.filter_is_sticky = True

        clone._include_limit = kwargs.pop('limit_includes', None)
        assert not kwargs, '"limit_includes" is the only accepted kwargs. Eat your heart out 2.7'

        # Copy the behavior of .select_related(None)
        if fields == (None, ):
            for field in clone._includes.keys():
                clone.query._annotations.pop('__{}'.format(field.name), None)
            clone._includes.clear()
            return clone

        # Parse everything the way django handles joins/select related
        # Including multiple child fields ie .include(field1__field2, field1__field3)
        # turns into {field1: {field2: {}, field3: {}}
        for name in fields:
            ctx, model = clone._includes, clone.model
            for spl in name.split('__'):
                field = model._meta.get_field(spl)
                if isinstance(field, ForeignObjectRel) and field.is_hidden():
                    raise ValueError('Hidden field "{!r}" has no descriptor and therefore cannot be included'.format(field))
                model = field.related_model
                ctx = ctx.setdefault(field, OrderedDict())

        for field in clone._includes.keys():
            clone._include(field)

        return clone
320885
function createRelatedTo() {
    $cnt = count( $this->relatedto );
    if( 0 >= $cnt )
      return;
    $output = null;
    foreach( $this->relatedto as $relation ) {
      $attributes = $this->_createParams( $relation['params'] );
      $content    = '<'.$this->_strrep( $relation['value'] ).'>';
      $output    .= $this->_createElement( 'RELATED-TO', $attributes, $content );
    }
    return $output;
  }
172062
def set_relation_many_to_many(self, obj, field_name, objs):
        ""
        relation = getattr(obj, field_name)
        if hasattr(relation, 'set'):
            relation.set(objs) # Django 2.x
        else:
            setattr(obj, field_name, objs)
662275
def _create_embedded_indices(self):
        '''
        
        '''
        try:
            self._target._embedded_indices.update(((k,(self,v)) for k,v in getattr(self._parser.typedef, 'inline_names', {}).items()))
        except AttributeError:
            pass
537322
def create_from(cls, another, **kwargs):
        
        reused_fields = {}
        for field, value in another.get_fields():
            if field in cls.FIELDS:
                reused_fields[field] = value
        reused_fields.update(kwargs)
        return cls(**reused_fields)
844050
def attach_related_file(self, path, mimetype=None):
        """"""
        filename = os.path.basename(path)
        content = open(path, 'rb').read()
        self.attach_related(filename, content, mimetype)
221764
def related_lua_args(self):
        ''''''
        related = self.queryelem.select_related
        if related:
            meta = self.meta
            for rel in related:
                field = meta.dfields[rel]
                relmodel = field.relmodel
                bk = self.backend.basekey(relmodel._meta) if relmodel else ''
                fields = list(related[rel])
                if meta.pkname() in fields:
                    fields.remove(meta.pkname())
                    if not fields:
                        fields.append('')
                ftype = field.type if field in meta.multifields else ''
                data = {'field': field.attname, 'type': ftype,
                        'bk': bk, 'fields': fields}
                yield field.name, data
466636
def _make_embedded_from(self, doc):
        ''''''
        ld = utils.CurieDict(self._core.default_curie, {})
        for rel, doc in doc.get('_embedded', {}).items():
            if isinstance(doc, list):
                ld[rel] = [self._recursively_embed(d) for d in doc]
            else:
                ld[rel] = self._recursively_embed(doc)
        return ld