On Saturday, September 14, 2013 5:54:47 AM UTC-7, Niphlod wrote:
the syntax is more or less:
db(filter).select(thefieldsyouneed)
so, your conditions must be inside the db() and not the select()
Wow! That fixed *my* code! Thanks!
(I did have a workaround with db.executesql(), but it's
Currently I'm doing this and it works as expected:
controller:
items =db().select(db.t_items.ALL,cache=(cache.ram,10),cacheable=True)
return dict(items=items)
view:
{{for item in items:}}
{{if item.f_item_category == int(request.args(0)):}}
displays items belonging to a specific category
the syntax is more or less:
db(filter).select(thefieldsyouneed)
so, your conditions must be inside the db() and not the select()
On Saturday, September 14, 2013 12:09:31 PM UTC+2, אבי אברמוביץ wrote:
Currently I'm doing this and it works as expected:
controller:
items
Great, thanks , that works. Putting the conditions in the db(), probably
the only option i didn't try... :).
On Sunday, September 1, 2013 12:25:32 AM UTC+3, אבי אברמוביץ wrote:
Hi,
I do this query:
items = db.executesql('SELECT * FROM project;')
For the field below, which is a field in the
Alright, thanks.
What is a better practice, to create the query on the controller, pass the
list var to the view and there just display for example 30 times, or for
example create a 1, 30 range loop on the view, and create the query
directly there?
On Sunday, September 1, 2013 12:25:32 AM
It's generally best to keep business logic out of the view and limit the
view to just displaying data, so I would say the former.
Anthony
On Sunday, September 1, 2013 11:09:27 PM UTC-7, אבי אברמוביץ wrote:
Alright, thanks.
What is a better practice, to create the query on the controller,
index.html:
{{extend 'layout.html'}}
h2All projects:/h2
br/
{{for item in items: }}
{{=item[3]}}
{{pass}}
def_index:
items = db.executesql('SELECT * FROM project;')
return locals()
model:
db.define_table('company',
Field('company_name', notnull=True, unique=True),
Field('email'),
On Sunday, September 1, 2013 12:25:32 AM UTC+3, אבי אברמוביץ wrote:
Hi,
I do this query:
items = db.executesql('SELECT * FROM project;')
For the field below, which is a field in the db.project:
Field('company_name', 'reference company', notnull=True).
On the view, {{=item[3]}} renders
the validations puts it:
db.project.company_name.requires = IS_IN_DB(db, 'company',
'%(company_name)s')
ok!!
Ovidio Marinho Falcao Neto
ITJP.NET.BR
ovidio...@gmail.com
83 8826 9088 - Oi
83 9336 3782 - Claro
On Sunday, September 1, 2013 3:56:15 AM UTC-7, Ovidio Marinho wrote:
the validations puts it:
db.project.company_name.requires = IS_IN_DB(db, 'company',
'%(company_name)s')
First, you'll get that validator by default, so no need to specify it
explicitly. Second, in terms of display, that
Given the field definition:
Field('company_name', 'reference company', notnull=True)
and the fact that the db.company table has a format attribute, you will
get a default represent attribute for the db.project.company_name field
that displays the company name rather than its record ID.
Hi Anthony,
Thanks for that tutorial :).
I also tried the other method ( In a bit different syntax though: projects
= db(db.project).select()) , this is a better method (than the sql one)?
On Sunday, September 1, 2013 12:25:32 AM UTC+3, אבי אברמוביץ wrote:
Hi,
I do this query:
items =
I also tried the other method ( In a bit different syntax though:
projects = db(db.project).select())
Note, db().select(db.project.customer_name) will retrieve only the
customer_name field for each record from the database, so it is more
efficient if that is the only field you need. Your
Using the DAL for selects can make things easier, though using executesql
can be a bit faster (especially for large numbers of recrods) because it
doesn't parse the results into a Rows object (of course, then you lose the
benefits of working with Rows and Row objects).
Of course, the
I need to see more code.
On Saturday, 31 August 2013 16:25:32 UTC-5, אבי אברמוביץ wrote:
Hi,
I do this query:
items = db.executesql('SELECT * FROM project;')
For the field below, which is a field in the db.project:
Field('company_name', 'reference company', notnull=True).
On the view,
15 matches
Mail list logo