Hi all, I have a db table where I store some information and sometime a file like *.doc or *.pdf This is my model file
db.define_table('pratiche', Field('nome', requires=IS_NOT_EMPTY()), Field('descrizione', 'text', requires=IS_NOT_EMPTY()), Field('data_creazione', 'date'), Field('doc_filename'), Field('doc', 'upload')) I have a controller to insert, list and show the data into the table default.py def index(): rows = db(db.pratiche).select() return locals() @auth.requires_login() def create(): db.pratiche.data_creazione.default = request.now db.pratiche.data_creazione.writable=False db.pratiche.data_creazione.readable=False """ record = db.pratiche(request.args(0)) or redirect(URL('index')) url = URL('download') form = SQLFORM(db.pratiche, record, deletable=True, upload=url) if request.vars.image!=None: form.vars.doc_filename = request.vars.doc.filename if form.process().accepted: response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' return dict(form=form) """ form = SQLFORM(db.pratiche).process() if form.accepted: redirect(URL('index')) return locals() def show(): pratica = db.pratiche(request.args(0,cast=int)) return locals() def download(): return response.download(request, db) And I have a view to show the data index.html {{extend 'layout.html'}} <h2>Pratiche</h2> <table class="table"> <tr> <th>Nome pratica</th> <th>Allegati</th> <th>Data Creazione</th> </tr> {{for row in rows:}} <tr> <td><a href="{{=URL('show', args=row.id)}}">{{=row.nome}}</a></td> <td><a href="{{=URL('show', args=row.doc)}}">{{=row.doc}}</a></td> <td>{{=row.data_creazione}}</td> </tr> {{pass}} </table> My problem is that in the view index.html i show row.doc value that is retrive from db but is not alway set. How can I configure a if statement to say if "there is the upload file" show the name else "show label no attached file" Thank a lot. -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.