db.define_table(
'auth_user',
Field('id'),
Field('first_name', type='string',
label=T('First Name')),
Field('last_name', type='string',
label=T('Last Name')),
Field('email', type='string',
label=T('Email')),
Field('password', type='password',
readable=False,
label=T('Password')))
db.define_table(
'sale',
Field('id', db.auth_user, default=auth.user_id),
Field('start_date', 'date', requires=IS_DATE()),
Field('end_date', 'date', requires=IS_DATE()),
Field('start_time', 'time', requires = IS_TIME()),
Field('end_time', 'time', requires = IS_TIME()))
db.define_table(
'product',
Field('sale_id', db.sale),
Field('name', requires = IS_NOT_EMPTY()),
Field('price', 'double', default=0.00),
Field('description','text'),
Field('image', 'upload', default=''),
format = '%(name)s %(price)s')
def sale():
form = SQLFORM(db.sale)
if form.process().accepted:
response.flash = 'Auction Created'
redirect(URL('properties'))
return dict(form=form)
In the above code, I have 3 db tables in the db.py file (user, sale and
product). In addition, I have defined the 'sale' function in the default.py
file in the controller. The issue that I am experiencing is that when I
create a new sale, the user id shows up in the sales form, but when I
submit the sales form and redirect to the product form, the sale id field
is blank. I thought the "Field('sale_id', db.sale)," would have reference
the sale id in the product form. What am I missing?
--
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/groups/opt_out.