Add the slug to the model.
338443
protected function createSlug()
    {
        $slug = $this->generateNonUniqueSlug();

        if ($this->slugOptions->generateUniqueSlug) {
            $slug = $this->makeSlugUnique($slug);
        }

        $this->attributes[$this->slugOptions->slugField] = $slug;
    }
1358383
def add_columns(self, model, **fields):
        """"""
        for name, field in fields.items():
            model._meta.add_field(name, field)
            self.ops.append(self.migrator.add_column(
                model._meta.table_name, field.column_name, field))
            if field.unique:
                self.ops.append(self.migrator.add_index(
                    model._meta.table_name, (field.column_name,), unique=True))
        return model
422047
def pre_save(self, instance, add):
        
        # get currently entered slug
        value = self.value_from_object(instance)
        slug = None

        # auto populate (if the form didn't do that already).
        # If you want unique_with logic, use django-autoslug instead.
        # This model field only allows parameters which can be passed to the form widget too.
        if self.populate_from and (self.always_update or not value):
            value = getattr(instance, self.populate_from)

        # Make sure the slugify logic is applied,
        # even on manually entered input.
        if value:
            value = force_text(value)
            slug = self.slugify(value)
            if self.max_length < len(slug):
                slug = slug[:self.max_length]

        # make the updated slug available as instance attribute
        setattr(instance, self.name, slug)
        return slug
79902
def save(self, *args, **kwargs):
        
        if self.slug is None or self.slug == "":
            self.slug = slugify(self.name)

        feature_type = super(FeatureType, self).save(*args, **kwargs)

        if self.instant_article_is_dirty:
            index_feature_type_content.delay(self.pk)

        self._db_instant_article = self.instant_article

        # Run all behaviors for `create`
        if self.is_new:
            update_feature_type_rates.delay(self.pk)

        return feature_type
1175822
def add_model(self, ic, N=1, index=0):
        
        if type(index) in [list,tuple]:
            if len(index) != N:
                raise ValueError('If a list, index must be of length N.')
        else:
            index = [index]*N

        for idx in index:
            existing = self.get_system(idx)
            tag = len(existing)
            self.add_child(ModelNode(ic, index=idx, tag=tag))
64392
def auto_slug_on_insert(mapper, connection, target):
    """"""
    if target.slug is None and target.name:
        target.slug = target.auto_slug
48009
function(model, options) {
      model = this._prepareModel(model, options);
      this.add(model, _.extend({at: 0}, options));
      return model;
    }
924417
def save(self, **kwargs):
        """"""
        try:
            return super().save(**kwargs)
        except SlugError as error:
            raise ParseError(error)
865118
def _add(self):
        
        is_valid_form = True
        get_filter_args(self._filters)
        exclude_cols = self._filters.get_relation_cols()
        form = self.add_form.refresh()

        if request.method == "POST":
            self._fill_form_exclude_cols(exclude_cols, form)
            if form.validate():
                self.process_form(form, True)
                item = self.datamodel.obj()
                form.populate_obj(item)

                try:
                    self.pre_add(item)
                except Exception as e:
                    flash(str(e), "danger")
                else:
                    if self.datamodel.add(item):
                        self.post_add(item)
                    flash(*self.datamodel.message)
                finally:
                    return None
            else:
                is_valid_form = False
        if is_valid_form:
            self.update_redirect()
        return self._get_add_widget(form=form, exclude_cols=exclude_cols)
1299683
def view_or_add(self, slug):
        '''
        
        '''
        rec_page = MWiki.get_by_uid(slug)

        if rec_page:
            if rec_page.kind == self.kind:
                self.view(rec_page)
            else:
                return False
        else:
            self.to_add(slug)
711264
protected function addLastModel()
    {
        if (!$this->lastModelPopulator) {
            return;
        }

        $this->addOwners($this->lastModelPopulator->getOwners());

        $this->modelPopulators[$this->lastModelClass] = $this->lastModelPopulator;
        $this->quantities[$this->lastModelClass] = $this->lastQuantity;
    }
570710
public function addColumn()
    {
        $model = $this->models->first();

        $new_column = forward_static_call_array([new Column(), 'create'], func_get_args());

        $new_column->setOptionsFromModel($model);

        $this->columns[] =& $new_column;

        return $new_column;
    }
1072249
def add(self, term):
        """"""
        self._value = self.accum_param.addInPlace(self._value, term)
729189
public function actionCreate( $slug ) {

        $post   = $this->modelService->getBySlug( $slug, true );

        $this->view->params[ 'model' ]  = $post;

        $this->view->params[ 'step' ]   = 'content';

        if( isset( $post ) ) {

            $model          = new Block();
            $modelBlock     = new ModelBlock();

            $model->siteId  = Yii::$app->core->site->id;

            if( $model->load( Yii::$app->request->post(), $model->getClassName() ) ) {

                $this->blockService->create( $model );

                $modelBlock->modelId    = $model->id;
                $modelBlock->parentId   = $post->id;
                $modelBlock->parentType = $post->type;

                $this->modelBlockService->create( $modelBlock );

                // Create Gallery
                $gallery            = new Gallery();
                $gallery->name      = $model->name;
                $gallery->siteId    = Yii::$app->core->siteId;
                $modelGallery       = $this->modelGalleryService->create( $gallery, [ 'parentId' => $model->id, 'parentType' => CmsGlobal::TYPE_BLOG_CONTENT ] );

                return $this->redirect( [ "update?slug=$model->slug&pslug=$post->slug" ] );
            }

            return $this->render( 'create', [
                'model' => $model,
                'post' => $post
            ] );
        }

        // Error- Page not found
		throw new NotFoundHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
    }
833815
public function add()
    {
        $this->view = 'scaffold/add';
        $form = new Form(
            "add-{$this->get('modelSingular')}", $this->getDescriptor()
        );
        if ($this->request->isPost()) {
            $form->setData($this->request->getPost());
            if ($form->isValid()) {
                try {
                    $modelClass = $this->getModelName();
                    /** @var Model $model */
                    $model = new $modelClass($form->getValues());
                    $model->save();
                    $name = ucfirst($this->get('modelSingular'));
                    $this->addSuccessMessage(
                        "{$name} successfully created."
                    );
                    $pmk = $model->getPrimaryKey();
                    $this->redirect(
                        $this->_basePath .'/'.
                        $this->get('modelPlural').'/show/'.$model->$pmk
                    );
                    return;
                } catch (Database\Exception $exp) {
                    $this->addErrorMessage(
                        "Error while saving {$this->get('modelSingular')}} " .
                        "data: {$exp->getMessage()}"
                    );
                }
            } else {
                $this->addErrorMessage(
                    "Cannot save {$this->get('modelSingular')}. " .
                    "Please correct the errors bellow."
                );
            }
        }
        $descriptor =  $this->getDescriptor();
        $this->set(compact('form', 'descriptor'));
    }
646381
function(model, options) {
      var coll = this;
      options || (options = {});
      model = this._prepareModel(model, options);
      if (!model) return false;
      var success = options.success;
      options.success = function(nextModel, resp, xhr) {
        coll.add(nextModel, options);
        if (success) success(nextModel, resp, xhr);
      };
      model.save(null, options);
      return model;
    }
1372918
public function updateUrl($model)
    {
        $this->url = '';
        $category = $this->eloqent()->where('id', $model->category_id)->first();

        if ($category) {
            $this->url = $this->getURLPrefix() . $category->url . '/' . $this->slug . $this->getURLPosfix();
        }

        return $this;
    }