Linkto and Fields Mutually Exclusive

31 views
Skip to first unread message

Douglas Krueger

unread,
Aug 11, 2023, 12:55:48 PM8/11/23
to web2py-users
Hi, new to Web2py, going through the book, currently on chapter 7. I'm trying to get both the linkto (person's dogs) link to display on the view and to not display the person.image.filename. It seems if I allow  person.image.filename to be displayed then the file name from the image doesn't get stored in the DB. Is this normal behavior? I'm sure I'm doing something wrong. Any help would be appreciated. 

def forms():
    record = db.person(request.args(0))
    url = URL('download')
    link = URL('list_records', args='db')
    form = SQLFORM(db.person, record, deletable=True, upload=url,
                  linkto=link, labels = {'dog.owner':"This person's dogs"}),
                  fields=['name', 'gender', 'married', 'profile', 'image'])

    if request.vars.image != None:
        form.vars.image_filename = request.vars.image.filename
    if form.process().accepted:
        response.flash = 'form accepted'
    elif form.errors:
        response.flash = 'form has errors'
    return dict(form=form)

In general, I'm not clear what can sent back and forth between a controller and a view and it does that. Lot's of print statements to aid but slow going. Is there a resource for dummies? Much appreciated. 

Sorry if this double posted. I can't find the first one. 

Douglas Krueger

unread,
Aug 12, 2023, 5:20:48 PM8/12/23
to web2py-users
I found Massimo's videos from 10 years ago! Reading the Web2py book first was like figuring out how a refrigerator works from the wiring diagram.  I get it now. 
Reply all
Reply to author
Forward
0 new messages