All,
Consider the below code in my sample web2py application ---
----Model-- db.py ------
db.define_table('updates',
Field('description', 'text', label='Post An Update'),
Field('pfile','upload',label='Attach File', autodelete=True),
)
----Controller--- posts function in default.py------------------
def posts():
form = crud.create(db.updates)
if form.accepts(request.vars, session):
pass
updates = db(db.updates.id>0).select()
#print db._lastsql
return dict(updates = updates)
-----------View ---- posts.html-------------------
{{extend 'layout.html'}}
<h3> Posts </h3>
<hr />
<div id='divcontainer'>
<p>
{{if len(updates):}}
{{for myupdate in updates:}}
<p><b>{{=myupdate.description}}</b> </i>{{=myupdate.description}}</
i>
<br> file: {{=myupdate.pfile}}
</p>
{{pass}}</p>
{{else:}}
<h5>No new updates available ....</h5>
{{pass}}
Query - How do I serialize the view to show a link to files attached.
For example in above code, it should show me the file name (original
would be good or a general name like say - FILE ) as hyperlink to
download the same. With the current code it shows me only the name of
the encoded file and does not allow me to download (i.e no links)
Rahul