OK. Both parts are there in the view.
The input fields are not evaluated against Database though.
Even if I enter numbers that are there in DB, form responses with:
"There are no matching records in Database."

If the numbers are matching they should be displayed in the result
part of the search page.

I tried something like this aslo:

items=db(db.numbers.no_1==form.vars.no_1|\
            db.numbers.no_2==form.vars.no_2|\
            db.numbers.no_3==form.vars.no_3|\
            db.numbers.no_4==form.vars.no_4).select()

But it's not working either.


On 16 Wrz, 23:19, mdipierro <mdipie...@cs.depaul.edu> wrote:
> somewhere you still have in it
>
> {{=SQLTABLE(items,headers="fieldname:capitalize")}}
>
> which as we said only works {{if items:}}
>
> Please remove everything from the view.
> You should just have
>
> {{extend 'layout.html'}}
> {{=form}}
> {{=SQLTABLE(items,headers="fieldname:capitalize") if items else
> "nothing to see here"}}
>
> On Sep 16, 4:15 pm, elfuego1 <elfue...@gmail.com> wrote:
>
> > OK. Both parts are there in the view.
>
> > Now, when I go from index.html to search.html I get an error:
>
> > Traceback (most recent call last):
> >   File "gluon/restricted.py", line 188, in restricted
> >   File "F:\Programy\web2py\applications\myapp/views\default/
> > search.html", line 88, in <module>
> >   File "gluon/sqlhtml.py", line 1192, in __init__
> > AttributeError: 'list' object has no attribute 'colnames'
>
> > Line 88:
> > response.write(SQLTABLE(items,headers="fieldname:capitalize"))
>
> > On 16 Wrz, 22:02, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > You have a form:
>
> > > def search():
> > >     form=SQLFORM.factory(INPUT('no_1','integer'),     <= line 57
> > >       INPUT('no_2','integer'),
> > >       INPUT('no_3','integer'),
> > >       INPUT('no_4','integer'))
> > >     if form.accepts(request.vars,keepvalues=True):
> > >       items=db(db.numbers.no_1.contains(form.vars.no_1)|\
> > >             db.numbers.no_2.contains(form.vars.no_2)|\
> > >             db.numbers.no_3.contains(form.vars.no_3)|\
> > >             db.numbers.no_4.contains(form.vars.no_4)).select()
> > >     else: items=[]
> > >     return dict(form=form,items=items)
>
> > > you need to but both
>
> > > {{=form}}
>
> > > and
>
> > > {{=SQLTABLE(items,headers="fieldname:capitalize") if items else
> > > "nothing to see here"}}
>
> > > in the view
>
> > > On Sep 16, 2:25 pm, elfuego1 <elfue...@gmail.com> wrote:
>
> > > > I did as you told me. Now I don't have search form on my search page.
> > > > What do you mean by saying: >>it is only producing "nothing to see
> > > > here"
> > > > because there is no data.<<
> > > > There is data in DB waiting to be searched, but how am I supposed to
> > > > do that now when there is no input fields on search page?!
> > > > How do I get input fields and results for my search below?
>
> > > > This is some vicious circle...
>
> > > > On 16 Wrz, 02:47, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > It is working just not being called. The output you see comes from
> > > > > this code you have
>
> > > > > {try:}}{{=H2(message)}}{{except:}}{{=BEAUTIFY(response._vars)}}
> > > > > {{pass}}
>
> > > > > and you should remove it.
>
> > > > > The code I suggested:
>
> > > > > {{=SQLTABLE(items,headers="fieldname:capitalize") if items else
> > > > > "nothing to see here"}}
>
> > > > > is working all right but it is only producing "nothing to see here"
> > > > > because there is no data.
>
> > > > > On Sep 15, 6:56 pm, elfuego1 <elfue...@gmail.com> wrote:
>
> > > > > > Source code for search.html looks like that:
>
> > > > > > {{extend 'layout.html'}}
> > > > > > {{try:}}{{=H2(message)}}{{except:}}{{=BEAUTIFY(response._vars)}}
> > > > > > {{pass}}
> > > > > > {{=SQLTABLE(items,headers="fieldname:capitalize") if items else
> > > > > > "nothing to see here"}}
>
> > > > > > The output page looks like that:
>
> > > > > > form    :
> > > > > > No 1:
> > > > > > No 2:
> > > > > > No 3:
> > > > > > No 4:
>
> > > > > > items   :
> > > > > > numbers.id numbers.no_1 numbers.no_2 numbers.no_3 numbers.no_4
> > > > > > nothing to see here
>
> > > > > > As you can see aliasing is not working at the moment.
> > > > > > Moreover when I put numbers into fields (numbers that are in 
> > > > > > database)
> > > > > > - nothing happens.
> > > > > > Values are not checked against DB.
> > > > > > I only get flash message: "There are no matching records in 
> > > > > > Database",
> > > > > > although I know that these numbers are in DB...
>
> > > > > > Something is missing but I can't figure out what it is.
>
> > > > > > On 16 Wrz, 01:09, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > > > It is failing when items=[]
> > > > > > > replace
>
> > > > > > > {{=SQLTABLE(items,headers="fieldname:capitalize")}}
>
> > > > > > > with
>
> > > > > > > {{=SQLTABLE(items,headers="fieldname:capitalize") if items else
> > > > > > > "nothing to see here"}}
>
> > > > > > > On Sep 15, 5:12 pm, elfuego1 <elfue...@gmail.com> wrote:
>
> > > > > > > >      items=db(db.numbers.no_1.contains(form.vars.no_1)|\
> > > > > > > >             db.numbers.no_2.contains(form.vars.no_2)|\
> > > > > > > >             db.numbers.no_3.contains(form.vars.no_3)|\
> > > > > > > >             db.numbers.no_4.contains(form.vars.no_4)).select()
> > > > > > > >       if not items: response.flash="There are no matching 
> > > > > > > > records in
> > > > > > > > Database."
> > > > > > > >     else: items=[]
> > > > > > > >     return dict(form=form,items=items)
>
> > > > > > > > On 15 Wrz, 23:08, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > > > > > You get an error in
>
> > > > > > > > >  
> > > > > > > > > response.write(SQLTABLE(items,headers="fieldname:capitalize"))
>
> > > > > > > > > that seems to indicate items is not the result of a select 
> > > > > > > > > but a list.
> > > > > > > > > What is items?
>
> > > > > > > > > On Sep 15, 3:57 pm, elfuego1 <elfue...@gmail.com> wrote:
>
> > > > > > > > > > That doesn't work as planned.
>
> > > > > > > > > > First scenario.
> > > > > > > > > > I added the code you provided above and got error:
>
> > > > > > > > > > Error traceback
>
> > > > > > > > > > Traceback (most recent call last):
> > > > > > > > > >   File "gluon/restricted.py", line 188, in restricted
> > > > > > > > > >   File "F:\Programy\web2py\applications\myapp/views\default/
> > > > > > > > > > search.html", line 92, in <module>
> > > > > > > > > >   File "gluon/sqlhtml.py", line 1192, in __init__
> > > > > > > > > > AttributeError: 'list' object has no attribute 'colnames'
>
> > > > > > > > > > Line 92:
> > > > > > > > > > response.write(SQLTABLE(items,headers="fieldname:capitalize"))
>
> > > > > > > > > > This error shows when I'm on index.html page and I want to 
> > > > > > > > > > go to
> > > > > > > > > > search.html
>
> > > > > > > > > > Second scenario.
> > > > > > > > > > I didn't add
> > > > > > > > > > {{=SQLTABLE(items,headers="fieldname:capitalize")}}
> > > > > > > > > > to search.html page yet. I go from index.html to 
> > > > > > > > > > search.html page
> > > > > > > > > > first. Search page shows up with all my old code in it. I 
> > > > > > > > > > make the
> > > > > > > > > > change you suggested and only refresh the search.html and 
> > > > > > > > > > there I can
> > > > > > > > > > see the alias column names I wanted.
> > > > > > > > > > BUT I can't get there from index.html any more. I can see 
> > > > > > > > > > the changed
> > > > > > > > > > page only if I'm refreshing search page but not if I want 
> > > > > > > > > > to get there
> > > > > > > > > > from index.html page. The change in code blocks me somehow 
> > > > > > > > > > from going
> > > > > > > > > > there.
> > > > > > > > > > Can you tell me why? How to remove the error?
>
> > > > > > > > > > Best regards.
>
> > > > > > > > > > But when I'm on search.html page and add the line you gave 
> > > > > > > > > > me
> > > > > > > > > > Strange thing with link redirecting me to my search.html 
> > > > > > > > > > page.
> > > > > > > > > > When I'm on search.html
>
> > > > > > > > > > On 14 Wrz, 13:28, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > > > > > > > > > > yes in search.html
>
> > > > > > > > > > > remove this:
>
> > > > > > > > > > > {{try:}}{{=H2(message)}}{{except:}}{{=BEAUTIFY(response._vars)}}
> > > > > > > > > > > {{pass}}
>
> > > > > > > > > > > Add this:
>
> > > > > > > > > > > {{=SQLTABLE(items,headers="fieldname:capitalize")}}
>
> > > > > > > > > > > On Sep 13, 10:41 pm, elfuego1 <elfue...@gmail.com> wrote:
>
> > > > > > > > > > > > Where do you suggest I should add it? In search.html ?
>
> > > > > > > > > > > > {{try:}}{{=H2(message)}}{{except:}}{{=BEAUTIFY(response._vars)}}
> > > > > > > > > > > > {{pass}}
> > > > > > > > > > > > {{=SQLTABLE(items,headers={'numbers.no_1':'No 1'})}}
>
> > > > > > > > > > > > Then I get two rows of columns:
>
> > > > > > > > > > > > items   :
> > > > > > > > > > > > numbers.id      numbers.no_1    numbers.no_2    
> > > > > > > > > > > > numbers.no_3    numbers.no_4
> > > > > > > > > > > > numbers.no_5    numbers.no_6    numbers.date
> > > > > > > > > > > > numbers.id      No 1    numbers.no_2  No 2    
> > > > > > > > > > > > numbers.no_3  No 3
> > > > > > > > > > > > numbers.no_4  No 4      numbers.no_5  No 5      
> > > > > > > > > > > > numbers.no_6  No 6
> > > > > > > > > > > > numbers.date
>
> > > > > > > > > > > > Can you show me where should I add it?
>
> > > > > > > > > > > > On 13 Wrz, 21:16, mdipierro <mdipie...@cs.depaul.edu> 
> > > > > > > > > > > > wrote:
>
> > > > > > > > > > > > > You mean in items. That depends on how you display 
> > > > > > > > > > > > > them. Perhaps one
> > > > > > > > > > > > > of these:
>
> > > > > > > > > > > > > {{=SQLTABLE(items,headers={'numbers.no_1':'No1'})}}
>
> > > > > > > > > > > > > or
>
> > > > > > > > > > > > > {{=SQLTABLE(items,headers='fieldname:capitalize'}}}
>
> > > > > > > > > > > > > On Sep 13, 12:56 pm, elfuego1 <elfue...@gmail.com> 
> > > > > > > > > > > > > wrote:
>
> > > > > > > > > > > > > > I have desired aliases in form fields names but in 
> > > > > > > > > > > > > > result set I
> > > > > > > > > > > > > > receive:
>
> > > > > > > > > > > > > > items:  numbers.id  numbers.no_1  numbers.no_2  
> > > > > > > > > > > > > > numbers.no_3
> > > > > > > > > > > > > > numbers.no_4  numbers.date
>
> > > > > > > > > > > > > > I'd like to change column names in result
> > > > > > > > > > > > > > from: numbers.no_1
> > > > > > > > > > > > > > into: No 1
>
> > > > > > > > > > > > > > I also noticed that the values from the form are 
> > > > > > > > > > > > > > not checked in
> > > > > > > > > > > > > > Database. In DB I have a record:
> > > > > > > > > > > > > > no_1 = 1
> > > > > > > > > > > > > > no_2 = 3
> > > > > > > > > > > > > > no_3 = 13
> > > > > > > > > > > > > > no_4 = 16
>
> > > > > > > > > > > > > > But when I enter values 1,3,13,21 into the form 
> > > > > > > > > > > > > > fields and submit data
> > > > > > > > > > > > > > I always get: "There are no matching records in 
> > > > > > > > > > > > > > Database."
> > > > > > > > > > > > > > The result should show 3
>
> ...
>
> więcej >>

Reply via email to