Your are right, I need to change the links to default. This is what I have
done so far, sorry for confusion:
in controller:
def index():
links = [lambda row: A('Details',_href=URL('default','show',
args=[row.slug]))]
fields = [db.equipment.category, db.equipment.title, db.equipment.price]
grid = SQLFORM.grid(fields=fields,
links=links,
)
return dict(grid=grid)
def show():
try:
equipment = db.equipment[int(request.args(0))]
except:
equipment = db(db.equipment.slug ==
request.args(0)).select().first()
return equipment
and in models db.py:
db.define_table('equipment',
Field('title'),
...
Field('slug', compute=lambda row: IS_SLUG()(row.title)[0])
On Wednesday, August 22, 2012 11:49:49 PM UTC-6, Anthony wrote:
>
> equipment is the table.
>>
>
> Yes, but in your code, it simply said args=[equipment.slug]. If your db
> object has a table named "equipment", you would refer to it as
> db.equipment, but in any case, that would not be relevant here.
>
>
>> the equipment details page is 'show' or 'details'. In reality, I thought
>> I could get away with the default 'view' from sqlform.grid, using a
>> slug...but it appears I cannot, so I have to create a custom 'show' or
>> 'details' page. If I do
>> links = [lambda row: A('Details',_href=URL('show','show',
>> args=[row.slug]))]
>
>
>
>> i get a key error.
>>
>
> What is the key error? Is your grid selecting from the equipment table
> (with the slug field)?
>
> Why is the URL now URL('show', 'show')? Is the controller named show.py,
> with a function called show()? In the URL() function, the first argument
> should be the controller and the second the function.
>
> Anthony
>
--