这里是我的模型:BadValueError:属性xxxx是必需的,即使已经设置了xxxx属性? (谷歌应用程序引擎)
from google.appengine.ext import db
from google.appengine.ext.db import polymodel
class Item(polymodel.PolyModel):
title = db.StringProperty(required=True)
summary = db.StringProperty(required=True)
content = db.TextProperty(required=True)
createDate = db.DateTimeProperty(auto_now_add=True)
class Article(Item):
author = db.StringProperty()
和我的处理程序:
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
import models.model
class Test(webapp.RequestHandler):
def get(self):
create(100)
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Test')
self.response.out.write('<p>Created')
app = webapp.WSGIApplication([('/test/*', Test)], debug=True)
def create(count):
for i in range(0,count,1):
article = models.model.Article()
article.title = "Test title " + str(i)
article.author = "wliao"
article.summary = "this is a test " + str(i)
article.content = "this is the content of the article"
article.put()
def main():
run_wsgi_app(app)
if __name__ == "__main__":
main()
我的问题是,我已经设置了所需的性能,为什么我仍然在加载它得到这个错误在浏览器中:
回溯(最近通话最后一个): 文件 “/家/ wliao /编程/ GoogleAppEngineSDK /谷歌/ AppEngine上/转/ web应用/ 初始化 py” 为,线700,我ñ通话 handler.get(*组) 文件 “/home/wliao/Programming/MysteryLeague/src/controllers/test.py”,8号线,在获取 创建(100) 文件“/家/ wliao /programming/MysteryLeague/src/controllers/test.py“,第18行,创建 article = models.model.Article() 文件”/ home/wliao/Programming/GoogleAppEngineSDK/google/appengine/ext/db/init .py“,行910,init prop。 设置(个体经营,价值) 文件 “/家/ wliao /编程/ GoogleAppEngineSDK /谷歌/ AppEngine上/转/ DB/初始化 py” 为,线594,在设置 值= self.validate(值) 文件 “/家/ wliao /编程/ GoogleAppEngineSDK /谷歌/ AppEngine上/转/ DB/初始化 py” 为,线2627,在验证 值=超(UnindexedProperty,个体经营).validate(值) 文件“/home/wliao/Programming/GoogleAppEngineSDK/google/appengine/ext/db/init .py“,第621行,验证 raise BadValueError('Property%s is required'%self.name) BadValueError:属性内容为必填项
谢谢!
天哪,我完全错过了一部分,谢谢! – wliao 2011-05-26 18:31:27