好的,问题就在这里。我有这个代码
list_categories = [None,"mathematics","engineering","science","other"]
class Books(db.Model)
title = db.StringProperty(required=True)
author = db.StringProperty()
isbn = db.StringProperty()
categories = db.StringListProperty(default=None, choices = set(list_categories))
我在这里要做的是让我的 book.categories 成为列表类别的子集,例如我有一本书的类别应该是“工程”和“数学”,但是当我设置
book.categories = ['engineering','mathematics']
它 webapp2 给了我一个错误
BadValueError: Property categories is ['engineering','mathematics']; must be one of set([None,"mathematics","engineering","science","other"])
我最初的猜测是我必须将我的 list_choices 设置为 [None,"mathematics","engineering","science","other"] 的 POWERSET,但这太低效了。
有谁知道这个的解决方法?