문제

I need to change values for an entry, but the following code doesn't work.

logList = db.GqlQuery("SELECT * FROM Log ORDER BY date DESC LIMIT 1")
logList[0].content = "some text"
db.put(logList)

The value for the newest element doesn't change when I run this. I checked the output with Print, it gives correct value (to what the content field should be changed & the correct old value) and gives the following status code:

Status: 302 Moved Temporarily
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Location: http://localhost:8080/admin/editl
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 0

What is wrong with my code? The used method of altering data was mentioned in the official docs.

도움이 되었습니까?

해결책

logList = db.GqlQuery("SELECT * FROM Log ORDER BY date DESC LIMIT 1")
result = logList.get()
result.content = "some text"
result.put()

Try this. You are confusing the GqlQuery object for the results of actually eexecuting the query.

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