下面是我用于将新案例输入 GAE 数据存储的表单的代码。当我尝试输入表单时,我收到下面的类型错误,说我使用了意外的关键字参数。我是 python 新手,GAE 有人知道我做错了什么吗?
class Case(db.Model):
user = db.StringProperty(required = True)
title = db.StringProperty(required = True)
facts = db.TextProperty()
holding = db.TextProperty()
rule_of_law = db.TextProperty()
general_notes = db.TextProperty()
key_concepts = db.TextProperty()
class NewCase(Handler):
def get(self,title="",
facts="",
holding="",
rule_of_law="",
general_notes="",
key_concepts="",
error=""):
if self.user:
self.render('newcase.html', title=title,
facts=facts,
holding=holding,
rule_of_law=rule_of_law,
general_notes=general_notes,
key_concepts=key_concepts,
error=error)
else:
self.redirect('/login')
def post(self):
if not self.user:
self.redirect('/')
user = self.read_secure_cookie('user_id')
self.title = self.request.get('title')
self.facts = self.request.get('facts')
self.holding = self.request.get('holding')
self.rule_of_law = self.request.get('rule_of_law')
self.general_notes = self.request.get('general_notes')
self.key_concepts = self.request.get('key_concepts')
if self.title:
c = Case(user = user,
title = self.title,
facts = self.facts,
holding = self.holding,
rule_of_law = self.rule_of_law,
general_notes = self.general_notes,
key_concepts = self.key_concepts)
c.put()
self.redirect('/%s' % c.key().id())
else:
error = "You must enter a title."
self.render('newcase.html',title = self.title,
我得到的错误:
File "C:\Users\Chris\Documents\Web Apps\legalstudybuddy\main.py", line 233, in post
key_concepts = self.key_concepts)
TypeError: __init__() got an unexpected keyword argument 'rule_of_law'