I have also tried to the information from here - https://web2py.wordpress.com/category/web2py-and-tables/ but it also didn't work with the same error "NoneType' object is not iterable"
On Wednesday, 13 August 2014 22:14:46 UTC+2, Anna Kostikova wrote: > > Dear list, > > I am trying to create a search form to access a table in database and then > return a table of result into a view (same page), but displaying only 3 > records and next/prev buttons to scroll over results (e.g. I want to have > pagination of the table display results). I am trying to follow an example > from > http://web2py.com/books/default/chapter/29/14/other-recipes#Pagination, > but have some issues. > > My code in default.py is: > > def search(): > rows = None > page = 7 # fixing for a moment > items_per_page = 3 # fixing for a moment > form=FORM('Tool name:', > INPUT(_name='name', _id='name', requires=IS_NOT_EMPTY()), > INPUT(_type='submit')) > if form.accepts(request,session): > response.flash = 'form accepted' > if request.vars: > rows = db(db.mytools.name.contains(request.vars.name)).select( > db.mytools.name, db.mytools.description) > elif form.errors: > response.flash = 'form has errors' > else: > response.flash = 'please fill the form' > return dict(form=form, rows=rows, page=page, > items_per_page=items_per_page) > > If I have in search.html following code, everything works: > > {{=form}} > {{=rows}} > > but as soon as I try (the example from tutorial) > > {{for i,row in enumerate(rows):}} > {{if i==items_per_page: break}} > {{=row.value}}<br /> > {{pass}} > > {{if page:}} > <a href="{{=URL(args=[page-1])}}">previous</a> > {{pass}} > > {{if len(rows)>items_per_page:}} > <a href="{{=URL(args=[page+1])}}">next</a> > {{pass}} > > I have an error "NoneType' object is not iterable" > > What am i doing wrong? (i am newbie to web2py, so sorry if i have super > obvious code errors). > > Thanks a lot, > Anna > > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.