The Tables are in db.py(model)
def Article(): is in default.py(controler)
and the image Tag is in default/views/Article.html
I had no download function. I'm so stupid^^ no wonder it didn't work thanks
anthony your help isalways really good. It works now
For anyone reading this with the same problem the download function looks
like this:
def download():
return response.download(request, db)
and is located in default.py
On Monday, September 3, 2012 6:49:32 PM UTC+2, Anthony wrote:
>
> First, are all these functions in the same controller? If not, be sure to
> specify the controller in URL(). Also, what does your download() function
> look like?
>
> Anthony
>
> On Monday, September 3, 2012 12:32:19 PM UTC-4, BlueShadow wrote:
>>
>> I know this question has been asked multiple times but I still can't get
>> it to work. I got a table containing an image name:
>> db.define_table('Images',
>> Field('Name',length=512),
>> Field('Image','upload'),
>> Field('Source',db.Source),
>> format = '%(Name)s' # <<< important
>> )
>> db.Images.Quelle.requires=IS_IN_DB(db,'Source.id','Quelle.Source')
>>
>> Now I gat a table containing an article:
>> db.define_table('Article',
>> Field('Title',length=512),
>> Field('Content','text'),
>> Field('Sources',length=512),
>> Field('Submitted','datetime',default=datetime.datetime.now()),
>> Field('Views','integer',default=0),
>> Field('Author','reference auth_user',default=auth.user_id),
>> Field('TopImage',db.Images)
>> )
>>
>> In my controler I select the the Article which should be displayed:
>> def Article():
>> id=request.vars.id
>> row=db(db.Article.id==id).select()
>> if len(row)==0:
>> redirect(URL(r=request,f='Articles'))
>> return dict(Article=row[0])
>>
>> and in my View I do the following:
>> {{print URL('download',args=Article.TopImage.Image)}}
>> <center><img src="{{=URL('download',args=Article.TopImage.Image)}}" />
>> </center>
>> I tried replacing upload with download and various other things.
>> One of the Problems I think is that it is looking in delault. but the
>> upload folder where the picture lands is in /appname/upload/
>>
>> Thanks for your help
>>
>
--