[web2py] how to update a database field with a random value selected from a list using random.choice()

2020-07-15 Thread mostwanted
I thought it would be easy but its not, wrong values are being selected from wrong lists! After submitting a form I wanna check to see if the session field is either a single_session, double_session, evening_single_session or evening_double_session, depending on what it is I want time to be sel

Re: [web2py] Re: belongs to one table but not the other ...

2020-07-15 Thread Eliezer (Vlad) Tseytkin
Thank you! On Wed, Jul 15, 2020, 2:40 AM Andrew Rogers wrote: > Try adding a '~' in front of it. > > db(~(db.cart.id.belongs(another_table_select))).select(db.cart.id) > > See: > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=lazy#Logical-operators > > On Wed

[web2py] Re: how to update a database field with a random value selected from a list using random.choice()

2020-07-15 Thread villas
Before submission of form, use JS. or After submission, allocate the time in the controller using *onvalidation*. See http://www.web2py.com/books/default/chapter/29/07/forms-and-validators#onvalidation On Wednesday, 15 July 2020 13:58:28 UTC+1, mostwanted wrote: > > I thought it would be easy

[web2py] Re: Under what circumstances would db.define_table() return None

2020-07-15 Thread villas
You don't mention... - Which DB adapter you are using - Why just one of your tables is expected to be an in-memory table and the others not - Why you don't simply maintain the list of tables in a list(), or dict() or some other in-memory structure In any case, maybe this idea

[web2py] Re: how to update a database field with a random value selected from a list using random.choice()

2020-07-15 Thread mostwanted
Thank you Villas, i updated my controller like this & its giving results. I a sure there is a better way to do this, a ore cleaner way & if anyone cares to improve my code please dont hesitate so i could update mine & learn more: def my_form_processing(form): if form.vars.class_session=='si

[web2py] Re: how to update a database field with a random value selected from a list using random.choice()

2020-07-15 Thread villas
We all have our styles of programming. I would probably create a dict of times. But any idea which works is fine. Everyone looks at their old code and sees a better way. My motto is: get something working and move on! On Wednesday, 15 July 2020 19:26:33 UTC+1, mostwanted wrote: > > Thank

Re: [web2py] Re: how to update a database field with a random value selected from a list using random.choice()

2020-07-15 Thread AGRogers
>>>My motto is: get something working and move on! Haha. A modified version I need to remember: Get something working and don't go back and break it! On Thu, 16 Jul 2020, 7:20 am villas, wrote: > We all have our styles of programming. I would probably create a dict of > times. > But any idea

Re: [web2py] Re: how to update a database field with a random value selected from a list using random.choice()

2020-07-15 Thread mostwanted
Hahahaha sometimes you put in a single delimeter & it all comes down crumbling! On Thursday, July 16, 2020 at 2:22:45 AM UTC+2, AGRogers wrote: > > >>>My motto is: get something working and move on! > > Haha. A modified version I need to remember: Get something working and > don't go back and

[web2py] Re: how to update a database field with a random value selected from a list using random.choice()

2020-07-15 Thread mostwanted
The dictionary makes it less cubersome: def my_form_processing(form): times=dict({'single_session_times':['0830-0930hrs', '0930-1030hrs', '1100-1200','1200-1300', '1400-1500', '1500-1600', '1600-1700'], 'evening_single_session_times':['1730-1830', '1830-1930'], 'double_session_times':['0830-1