- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
GAE 快把我逼疯了。
我有以下内容:
if id_puertas[x]:
puerta = Puerta.get_by_id(int(id_puertas[x]))
puerta.ubicacion = ubicacion_puertas[x],
puerta.ancho = float(ancho_puertas[x]),
puerta.marco = float(marco_puertas[x]),
puerta.alto = float(alto_puertas[x]),
puerta.giro = giro_puertas[x],
puerta.condena = True if condena_puertas[x] == 'Si' else False,
puerta.extra = extra_puertas[x]
else:
puerta = Puerta(
medicion = medicion.key().id(),
ubicacion = ubicacion_puertas[x],
ancho = float(ancho_puertas[x]),
marco = float(marco_puertas[x]),
alto = float(alto_puertas[x]),
giro = giro_puertas[x],
condena = True if condena_puertas[x] == 'Si' else False,
extra = extra_puertas[x]
)
puerta.put()
相同的表单将 id_puerta
作为数字发送,或者发送空白。如果是数字,则更新数据存储中的实体。如果为空,则创建一个新实体。
创作完美。
但如果我重新发送相同的表格(即使没有修改),更新会在第一次分配时阻塞。
ubicacion_puertas[x]
是一个字符串(创建时与更新时的字符串相同),puerta.ubicacion
是一个 StringProperty,
但我收到以下错误:
BadValueError: Property ubicacion must be a str or unicode instance, not a tuple
在调试器中,我清楚地看到 ubicacion_puertas[0]
是 u'Salon'。所以我无法理解这个错误。
最佳答案
当你这样做时:
puerta.ubicacion=ubicacion_puertas[x],
你在 puerta
的 ubicacion
属性中存储了一个元组:另一种更具可读性的形式是:
puerta.ubicacion=(ubicacion_puertas[x],)
你确定这是你想要的吗?去掉 ,
来存储一个 str
puerta.ubicacion = ubicacion_puertas[x]
(其他属性也是一样...)
关于python - BadValueError : Property X must be a str or unicode instance, 不是元组(更新时,而不是创建时),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12743621/
我从 Google 应用引擎和验证器中获得了 ndb 模型。但是当我使用 postman 尝试验证并从 postman 生成的字符串中强制执行 int 时。我仍然收到 BadValueError:Ba
我试图通过使用将字符串转换为相应类型的 Key 的自定义验证器来简化 ndb KeyProperties 的 JSON 序列化和反序列化。 想法是拥有这样的属性: def key_validator(
我正在尝试删除数据存储中的记录。不幸的是,每当我尝试删除这些项目时,它都会给我一个 BadValueError,说 Districts(其中一列)是必需的。由于批量加载程序出现问题,所有行的 Dist
我正在使用 Python 创建 Google App Engine 应用程序。为了测试我的应用程序,我使用 html 表单输入数据。在我的表格中有一行: Age 在我的模型类中,属性定义如下: cla
这是我的模型: from google.appengine.ext import db from google.appengine.ext.db import polymodel class Item
bulkoader.yaml: transformers: - kind: ExampleModel connector: csv property_map:
GAE 快把我逼疯了。 我有以下内容: if id_puertas[x]: puerta = Puerta.get_by_id(int(id_puertas[x]))
我在本地运行 AppEngine。我对对象的以下属性使用了一些过滤器: class Blah(db.Model): access_code = db.StringProperty() 然后我在
我是一名优秀的程序员,十分优秀!