Ok... So I found the solution and it was a TOTAL noob mistake. Turns out that SQLFORM.grid() messes up with the requests arguments and in the initial examples of the book this is never mentioned.
In Chapter 7 of the book (english 6th edition) I found the answer: (http://web2py.com/books/default/chapter/29/07/forms-and-validators#Using-requests-args-safely) In order for the grid to work properly, I had to give it this parameter: *args=request.args[:1]* that way the Grid knows to preserve the first argument for the request. The code in the controller ended up working like this: @auth.requires_login() def testArg(): test = db.test(request.args(0,cast=int, otherwise=URL('index'))) or redirect(URL('index')) grid = SQLFORM.grid(db(db.test.id == 2), *args=request.args[:1]*, deletable=False, editable=True) return locals() On Wednesday, January 15, 2020 at 1:04:00 AM UTC-5, Juan Gutiérrez wrote: > > This sounds crazy but I'm getting an error 404 when using in the same > function this lines together: > > test = db.test(request.args(0,cast=int, otherwise=URL('index'))) or > redirect(URL('index')) > grid = SQLFORM.grid(db(db.test.id == 2), deletable=False, editable=True) > > When I comment either one of the lines, the function returns the correct > values for test and grid. When put together, it doesn't work and I get > redirected or a 404 error. > > the complete escenario is: > Request: > http://127.0.0.1/gk/default/testArg/1 > > Model: > db.define_table('test', > Field('nombre', 'string', unique=True, label='Nombre'), > Field('gerencia', label='Gerencia'), > Field('equipo', label='Equipo'), > Field('vigencia', 'date', label='Vigencia'), > format = '%(nombre)s' > ) > > Controler: > @auth.requires_login() > def testArg(): > test = db.test(request.args(0,cast=int, otherwise=URL('index'))) or > redirect(URL('index')) > grid = SQLFORM.grid(db(db.test.id == 2))#, deletable=False, > editable=True) > return locals() > > View: > generic.html > > Am I missing something really obvious? > > David. > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/d08b6b21-6c71-4b2c-9f4d-18f049b9a4b7%40googlegroups.com.