Question

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 ?

Was it helpful?

Solution

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))

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top