> > *db.define_table('pages',* > * Field('title', unique=True, notnull=True),* > * Field('slug', unique=True)* > *)* > > *db.pages.slug.compute = lambda row: IS_SLUG()(row.title)[0]* >
On Wed, Nov 30, 2011 at 1:24 PM, Anthony <abasta...@gmail.com> wrote: > If you're receiving the title from a form submission, you can use the > IS_SLUG validator on the title field, which will convert it to a slug > (remove non-alphanumeric characters and convert spaces to hyphens). You can > also use the validator on it's own: > > >>> title_slug = IS_SLUG()('Today is Wonderful!')[0] > >>> print title_slug > today-is-wonderful > > See http://web2py.com/book/default/chapter/07#Validators. > > Anthony > > On Wednesday, November 30, 2011 10:09:33 AM UTC-5, lyn2py wrote: >> >> If I want to create a link from a string, is there a function in >> web2py to do that? >> >> For example I have a post title "Today is Wonderful!" and I want to >> create >> >> /blog/show/today-is-wonderful >> instead of >> >> /blog/show/today-is-wonderful%**21 >> which gives a Invalid Request error... >> >> Thanks! >> >> >> -- Bruno Rocha [http://rochacbruno.com.br]