In my SQLForm.grid I added this
    links = [lambda row: A('Details',_href=URL('default','show', 
args=[equipment.slug]))]
    grid = SQLFORM.grid(query=query, links=links)


I also added the is_slug into the model...but get this error..

    links = [lambda row: A('Details',_href=URL('equipment','show', 
args=equipment.slug))]
AttributeError: 'function' object has no attribute 'slug'



On Tuesday, August 21, 2012 3:49:55 PM UTC-6, rochacbruno wrote:
>
> You want to create a slug?
>
> web2py comes with IS_SLUG validator which helps with this.
>
> db.define_table("product",
>     Field("title", unique=True),
>     ...
>     ...
>     Field("slug", compute=lambda row: IS_SLUG()(row.title)[0]
> )
>
> So now you can use slug field to build your urls.
>
>  URL("product", "show", args=product.slug)
>
> in product/show/product-name
>
> def show():
>     try:
>         product = db.product[int(request.args(0))]
>     except:
>         product = db(db.product.slug == request.args(0)).select().first()
>    return product
>
>
>
>
> On Tue, Aug 21, 2012 at 6:18 PM, SeamusSeamus 
> <morrisjam...@gmail.com<javascript:>
> > wrote:
>
>> I didnt mean to do {{ }}, but I mean domain.com/product/productname   
>> (Product name being the name of the variable in the field from the model)
>>
>>
>>
>> On Tuesday, August 21, 2012 2:43:35 PM UTC-6, Anthony wrote:
>>>
>>> What is {{fieldname title}}? How do you get that value?
>>>
>>> On Tuesday, August 21, 2012 4:31:54 PM UTC-4, SeamusSeamus wrote:
>>>>
>>>> Thanks, what about URLs so it is 
>>>> www.domain.com/product/{{**fieldname<http://www.domain.com/product/%7B%7Bfieldname>title}}
>>>>
>>>>
>>>> On Tuesday, August 21, 2012 10:56:49 AM UTC-6, Anthony wrote:
>>>>>
>>>>> You can set response.title and response.meta in the controller or 
>>>>> function to make it specific to particular controllers or functions (or 
>>>>> you 
>>>>> can set them conditionally in a model file). If you need to use a 
>>>>> database 
>>>>> value, just do a query to get the value (your probably want to cache it 
>>>>> to 
>>>>> improve performance).
>>>>>
>>>>> Anthony
>>>>>
>>>>> On Tuesday, August 21, 2012 12:49:00 PM UTC-4, SeamusSeamus wrote:
>>>>>>
>>>>>>
>>>>>> 1. What is the easiest way to make it so each page has it's own 
>>>>>> title? Currently it is set by layout.html, but what if I want its own 
>>>>>> page 
>>>>>> to have an independent title? 
>>>>>> 2. How can I make it so the <title> of the page is the "name" of a 
>>>>>> field in a model? I am using SQLForm now, and have /product/1 and would 
>>>>>> like to have /product/purple-desk
>>>>>> 3. How can I make it so the meta description on each page has its own 
>>>>>> ? For example, the description is the data in the field 'product 
>>>>>> description' used in the model.
>>>>>>
>>>>>> Thanks.
>>>>>
>>>>>  -- 
>>  
>>  
>>  
>>
>
>

-- 



Reply via email to