我正在使用python,django和谷歌应用引擎,我收到以下错误。但是,bookdescription
是TextProperty
而不是StringProperty
,所以我不明白为什么会发生多行错误。
错误是间歇性的,有时页面会呈现正常,有时则不会。我是编码的新手,所以非常感谢任何和所有的帮助!
模型定义如下所示:
class Book(db.Model):
list = db.ReferenceProperty(List)
booktitle = db.StringProperty()
bookauthor = db.StringProperty()
bookdescription = db.TextProperty()
added = db.DateTimeProperty(auto_now_add=True)
完整错误:
Property bookdescription is not multi-line
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/webapp/__init__.py", line 511, in __call__
handler.get(*groups)
File "/base/data/home/apps/7-books/3.345967110627358311/7books.py",
line 279, in get
self.response.out.write(template.render(path, template_values))
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/webapp/template.py", line 81, in render
return t.render(Context(template_dict))
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/webapp/template.py", line 121, in wrap_render
return orig_render(context)
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/__init__.py", line 168, in render
return self.nodelist.render(context)
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/__init__.py", line 705, in render
bits.append(self.render_node(node, context))
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/__init__.py", line 718, in render_node
return(node.render(context))
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/loader_tags.py", line 82, in render
return compiled_parent.render(context)
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/__init__.py", line 168, in render
return self.nodelist.render(context)
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/__init__.py", line 705, in render
bits.append(self.render_node(node, context))
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/__init__.py", line 718, in render_node
return(node.render(context))
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/loader_tags.py", line 23, in render
result = self.nodelist.render(context)
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/__init__.py", line 705, in render
bits.append(self.render_node(node, context))
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/__init__.py", line 718, in render_node
return(node.render(context))
File "/base/python_runtime/python_lib/versions/third_party/
django-0.96/django/template/defaulttags.py", line 99, in render
values = list(values)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/db/__init__.py", line 2012, in next
return self.__model_class.from_entity(self.__iterator.next())
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/db/__init__.py", line 1239, in from_entity
instance = cls(None, _from_entity=True, **entity_values)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/db/__init__.py", line 813, in __init__
prop.__set__(self, value)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/db/__init__.py", line 542, in __set__
value = self.validate(value)
File "/base/python_runtime/python_lib/versions/1/google/appengine/
ext/db/__init__.py", line 2453, in validate
raise BadValueError('Property %s is not multi-line' % self.name)
BadValueError: Property bookdescription is not multi-line
类看起来像这样:
class Displaylist(webapp.RequestHandler):
def get(self, id):
booklist = List.get_by_id(int(id))
books = booklist.book_set
list = booklist
creator = booklist.user
location = getip(self.request.remote_addr)
tld = gettld(location)
aff = getaff(location)
user = users.get_current_user()
if user:
loginout = users.create_logout_url("/")
username = user.email()
else:
loginout = users.create_login_url("/")
username = ''
template_values = {
'list': list,
'creator': creator,
'books': books,
'email': username,
'loginout': loginout,
'tld': tld,
'aff': aff,
}
path = os.path.join(os.path.dirname(__file__), 'templates/list.html')
self.response.out.write(template.render(path, template_values))
答案 0 :(得分:4)
似乎运行时环境以某种方式引用Book
模型的不同定义,其bookdescription
定义为StringProperty
,因为错误是从{{3}引发的}}
您是否有机会在多个地方定义Book
模型?