문제

I am working in google app engine , i want to redirect browser to the specific URL which is retrived from Datastore.

The model of stored URL is like,

class WebReference(db.Model):
    website = db.StringProperty()
    webreferecnce=db.StringProperty() 

My code is ,

query = db.GqlQuery("SELECT * FROM WebReference where webreferecnce = '10'")
            results = query.fetch(1)
            for r in results:
                self.redirect(r.website)

I want to redirect the URL to the website who have webreference number 10. This is running at localhost but not after uploading. how can i achieve this ?

도움이 되었습니까?

해결책

Try this one , this is worked for me, dont forget to convert url in string like str(YourURLgoesHere)

result = WebReference.gql("WHERE webreferecnce= :1", parameter)
    for record in result.run(limit=1):
        self.redirect(str(record.website))

다른 팁

You select where r.webreferecnce = '10' and then you redirect to the value of the field webreferecnce, which will be 10. Maybe you mean something like

self.redirect(r.website), if that's where your URL is stored. Basically, think through what you actually want to do.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top