You could do it in your model file
FIELD('when', 'datetime', default = request.utcnow),
This way the value is set when stored to database.
On Friday, February 19, 2016 at 11:37:46 PM UTC+1, Dave S wrote:
>
> I have an SQLFORM being used for a when-who-what type of function, for a
> table roughly like
>
> db.define_table('stuff',
> FIELD('where', 'string'),
> FIELD('when', 'datetime'),
> FIELD('who', 'string'),
> FIELD('what', 'something')) # 'something' is 'upload' in actual
> code, but I don't think that matters
>
>
>
> And my controller does
>
>
> def getit():
> response.flash = T("Hello, fill out the form")
> message = T("tell me stuff")
> form = SQLFORM(db.stuff, fields=['who', 'what'])
> form.vars.where = request.client
> if form.process().accepted:
> response.flash = "Yea!"
> else:
> response.flash = "Ooops!"
> return dict(form = form, message=message)
>
>
>
> I'd like to get the db.stuff.when field updated with the time of
> *submission*.. Would I do that as I did the where field? (using*
> request.utcnow)*. That gets the request time of the submitting, not the
> time the empty form is built when the user first decides to tell me stuff?
> (Normally, the difference isn't important, but if the user wanders off for
> a cuppa and sees Teddy using the copier and they start discussing the
> football pools .....
>
> /dps
>
>
--
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.