Save model for every language so that field auto-population
        is done for every each of it.
170408
def save_model(self, request, obj, form, change):
        
        super(DisplayableAdmin, self).save_model(request, obj, form, change)
        if settings.USE_MODELTRANSLATION:
            lang = get_language()
            for code in OrderedDict(settings.LANGUAGES):
                if code != lang:  # Already done
                    try:
                        activate(code)
                    except:
                        pass
                    else:
                        obj.save()
            activate(lang)
970677
def save(self, *args, **kwargs):
        
        lexer = get_lexer_by_name(self.language)
        linenos = self.linenos and 'table' or False
        options = self.title and {'title': self.title} or {}
        formatter = HtmlFormatter(style=self.style, linenos=linenos,
                                  full=True, **options)
        self.highlighted = highlight(self.code, lexer, formatter)
        super(Snippet, self).save(*args, **kwargs)

        # limit the number of instances retained
        snippets = Snippet.objects.all()
        if len(snippets) > 100:
            snippets[0].delete()
936406
def save_model(model, output_file):
    """"""
    if not output_file:
        return

    with open(output_file, 'wb') as f:
        pickle.dump(model, f)
    print("Saved model to file '{}'.".format(output_file))
1181295
public function saveTranslation()
    {
        $ret = true;

        foreach ($this->_models as $language => $model) {
            $dirty = $model->getDirtyAttributes();
            // we do not need to save anything, if nothing has changed or translation is equal to its fallback
            if (empty($dirty) || ($this->skipSavingDuplicateTranslation && $model->isNewRecord && $this->modelEqualsFallbackTranslation($model, $language))) {
                continue;
            }
            /** @var \yii\db\ActiveQuery $relation */
            $relation = $this->owner->getRelation($this->relation);
            $pks = $relation->link;

            foreach ($pks as $fk => $pk) {
                $model->$fk = $this->owner->$pk;
            }

            if (!$model->save()) {
                $ret = false;
            }
        }

        return $ret;
    }
92468
public function saveSeoContent() {
		$model = $this->getSeoContentModel();
		if (!$model->is_global) {
			$model->title = $this->owner->{$this->titleAttribute};
			$model->keywords = $this->owner->{$this->keywordsAttribute};
			$model->description = $this->owner->{$this->descriptionAttribute};
			$model->save();
		}
	}
659282
function (next, model) {
            var loaded = this.associationLoaded(model), val;
            if (loaded && (val = this.getAssociation(model))) {
                this._setAssociationKeys(model, val);
                val.save().classic(next);
            } else {
                next();
            }
        }
660400
public function saveAttribute()
    {
        $language = current($this->getLanguages());
        if ($language !== Yii::$app->language) {
            $this->identity->{$this->languageAttribute} = Yii::$app->language;
            $this->identity->save(true, [$this->languageAttribute]);
        }
    }
982858
private void populateModel()
   {
      if (m_count != 0)
      {
         m_count = 0;
         Arrays.fill(m_flags, false);
      }

      for (Task task : m_parentFile.getTasks())
      {
         for (int loop = 0; loop < MPXTaskField.MAX_FIELDS; loop++)
         {
            if (!m_flags[loop] && isFieldPopulated(task, MPXTaskField.getMpxjField(loop)))
            {
               m_flags[loop] = true;
               m_fields[m_count] = loop;
               ++m_count;
            }
         }
      }

      //
      // Ensure the the model fields always appear in the same order
      //
      Arrays.sort(m_fields);
      System.arraycopy(m_fields, m_fields.length - m_count, m_fields, 0, m_count);
   }
474710
def _set_auto_fields(self, model_obj):
        """"""
        for field_name, field_obj in \
                self.entity_cls.meta_.auto_fields:
            counter_key = f'{self.schema_name}_{field_name}'
            if not (field_name in model_obj and model_obj[field_name] is not None):
                # Increment the counter and it should start from 1
                counter = next(self.conn['counters'][counter_key])
                if not counter:
                    counter = next(self.conn['counters'][counter_key])

                model_obj[field_name] = counter
        return model_obj
52352
def save(self):
        
        assert self.__class__ in conf.config._registry,\
            '%(class_name)s is not registered' % {
                'class_name': self.__class__.__name__
            }

        ConfigModel = apps.get_model('djconfig.Config')

        for field_name, value in self.cleaned_data.items():
            value = utils.serialize(
                value=value,
                field=self.fields.get(field_name, None))
            # TODO: use update_or_create
            count = (ConfigModel.objects
                .filter(key=field_name)
                .update(value=value))
            if not count:
                ConfigModel.objects.create(
                    key=field_name,
                    value=value)

        count = (ConfigModel.objects
            .filter(key='_updated_at')
            .update(value=str(timezone.now())))
        if not count:
            ConfigModel.objects.create(
                key='_updated_at',
                value=str(timezone.now()))

        conf.config._reload()
1138421
def handle(self, locale, app=None, **options):
        
        translation.activate(settings.LANGUAGE_CODE)
        if app:
            unpack = app.split('.')

            if len(unpack) == 2:
                models = [get_model(unpack[0], unpack[1])]
            elif len(unpack) == 1:
                models = get_models(get_app(unpack[0]))
        else:
            models = get_models()
            
        for model in models:
            if hasattr(model, 'localized_fields'):
                i18n.unregister(model)
                model_full_name = '%s.%s' % (model._meta.app_label, model._meta.module_name)
                update_instances = set()
                messages = []
                
                for instance in model.objects.all():
                    for field in model.localized_fields:
                        local_field_name = get_real_fieldname(field, locale)
                        
                        if  hasattr(instance, local_field_name):
                                local_field_value = getattr(instance, local_field_name)
                                if local_field_value not in (None, u''):
                                    setattr(instance, local_field_name, None)
                                
                                    update_instances.add(instance)
                                    messages.append(u"%s %s %s : %s will become reset to None" % (model_full_name, instance, local_field_name, force_unicode(local_field_value)))

                if len(update_instances):
                    if self.ask_for_confirmation(messages, u'%s.%s' % (model._meta.app_label, model._meta.module_name)):
                        for update_instance in update_instances:
                            print u"resetting %s" % update_instance
                            update_instance.save()
326717
def save_translations(self, instances):
        
        if not isinstance(instances, (list, tuple)):
            instances = [instances]

        for instance in instances:

            translations = []

            for obj in instance._linguist.translation_instances:
                if obj.field_name:
                    obj.object_id = instance.pk
                    if (obj.is_new and obj.field_value) or (
                        obj.has_changed and not obj.is_new
                    ):
                        field = instance.get_field_object(obj.field_name, obj.language)
                        if hasattr(field, "pre_save") and callable(field.pre_save):
                            obj.field_value = field.pre_save(instance, True)

                    translations.append(obj)

            to_create = [
                (obj, self.model(**obj.attrs))
                for obj in translations
                if obj.is_new and obj.field_value
            ]
            to_update = [
                obj for obj in translations if obj.has_changed and not obj.is_new
            ]
            to_delete = [obj for obj in translations if obj.deleted]

            created = True

            if to_create:
                objects = [obj for cached, obj in to_create]
                try:
                    with transaction.atomic():
                        self.bulk_create(objects)
                except IntegrityError:
                    created = False

            if to_update:
                for obj in to_update:
                    self.filter(**obj.lookup).update(field_value=obj.field_value)
                    obj.has_changed = False

            if created:
                for cached, obj in to_create:
                    cached.is_new = False
                    cached.has_changed = False

            if to_delete:
                for obj in to_delete:
                    self.filter(**obj.lookup).delete()
                    obj.has_changed = False
1331954
def save(self, *args, **kwargs):
        
        # auto fill updated field with current time unless explicitly disabled
        auto_update = kwargs.get('auto_update', True)
        if auto_update:
            self.updated = now()

        # remove eventual auto_update
        if 'auto_update' in kwargs:
            kwargs.pop('auto_update')

        super(BaseDate, self).save(*args, **kwargs)
1095717
private function setLangProperties()
    {
        if (empty($this->obElement) || !$this->obElement->isClassExtendedWith('RainLab.Translate.Behaviors.TranslatableModel')) {
            return;
        }

        //Check translate model property
        if (empty($this->obElement->translatable) || !is_array($this->obElement->translatable)) {
            return;
        }

        //Get active lang list from Translate plugin
        $arLangList = self::getActiveLangList();
        if (empty($arLangList)) {
            return;
        }

        //Process translatable fields
        foreach ($this->obElement->translatable as $sField) {
            //Check field name
            if (empty($sField) || (!is_string($sField) && !is_array($sField))) {
                continue;
            }

            if (is_array($sField)) {
                $sField = array_shift($sField);
            }

            if (!isset($this->arModelData[$sField]) || array_key_exists($sField, (array) $this->obElement->attachOne) || array_key_exists($sField, (array) $this->obElement->attachMany)) {
                continue;
            }

            //Save field value with different lang code
            foreach ($arLangList as $sLangCode) {
                $sLangField = $sField.'|'.$sLangCode;
                $sValue = $this->obElement->lang($sLangCode)->$sField;
                $this->setAttribute($sLangField, $sValue);
            }
        }
    }
822404
def save_all(self):
        
        for index in range(self.get_stack_count()):
            if self.data[index].editor.document().isModified():
                self.save(index)
1332684
def save_model(self, fname):
        
        if self.model is None:
            self.make_model()

        with open(fname, 'wb') as fh:
            fh.write(self.model.encode('utf-8'))
348419
def save_new(self, form, commit=True):
        
        kwargs = {self.fk.get_attname(): self.instance.pk}
        new_obj = self.model(**kwargs)
        self._prepare_multilingual_object(new_obj, form)
        return forms.save_instance(form, new_obj, exclude=[self._pk_field.name], commit=commit)