links to specific records in table

52 views
Skip to first unread message

Kajetan Wardziński

unread,
May 5, 2014, 7:15:00 PM5/5/14
to web...@googlegroups.com
Hello, my first app and I'm stuck.
I generate table with SQLTABLE in Views like this:
{{=SQLTABLE(query, headers='fieldname:capitalize', linkto='table_manage')}}
and links in generated table doesn't link directly to the specific record in the database, I have also "not authorized" message
It should be Digitally signed urls, but I don't kno how to use it
thanks

Kyle Flanagan

unread,
May 6, 2014, 9:59:44 AM5/6/14
to web...@googlegroups.com
It's normally a good idea to construct your SQLTABLE in your controller and then pass it to your view,

e.g.:

default.py
def index():
   query
= db().select(....)
   table
= SQLTABLE(query,headers='fieldname:capitalize', linkto='table_manage')

default/index.html
{{extend 'layout.html'}}

{{=table}}

That being said, linkto is expecting a function to generate a URL. Is table_manage a function?

Also, I'm not exactly sure what you're trying to accomplish, but SQLFORM.grid or SQLFORM.smartgrid may already do what you're looking for. http://web2py.com/books/default/chapter/29/07/forms-and-validators?search=smartgrid#SQLFORM-grid-and-SQLFORM-smartgrid

Kajetan Wardziński

unread,
May 6, 2014, 4:31:16 PM5/6/14
to web...@googlegroups.com
thanks,
works in the same way, I have table with links and when I click on it I have message "not authorized" and nothing happen.
I try to select some rows from table and display them in Views, with links to edit or view single record from table

SQLFORM is a good idea but there is another problem:
i have following query in model:
query = db((db.t_database.f_field == 'No') & (db.t_database.f_anotherField == 'Yes')).select()
and in Controllers:
def function():
    table
= SQLFORM.smartgrid(db.t_database, constraints = dict(t_database = query))
   
return locals()
and View:
{{extend 'layout.html'}}

{{=table}}

and there is following error:
Query Not Supported: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '9, at line 2")
when I run the same query with SQLTABLE it works fine
Reply all
Reply to author
Forward
0 new messages