Change your expectations :P
You are inserting into database while generating the view, before view even
gets to the client (browser).
Your "href" needs to point to a controller, for example:
<a href="{{=URL('mycontroller', 'my_insert_function', args=[x.id])}}">{{=
x.name}}</a>
Then, in "mycontroller.py" file you need to have a "my_insert_function"
like this:
def my_insert_function():
_id = request.args(0)
db.store.insert(stuff = _id)
redirect(URL('othercontroller', 'otherfunction)) # <-- you can use this
to go back to original page
On Sun, Jan 3, 2016 at 3:36 PM, RAGHIB R <[email protected]> wrote:
> {{for x in uu:}}
> <a href= {{db.store.insert(stuff=x.id)}}>
> {{=x.name}}
> </a>
> {{pass}}
> This doesn't work as expected. How to fix it?
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.