target_type -- can be a Python object or a redisco model class.
If target_type is not a redisco model class, the target_type should
also a callable that casts the (string) value of a list element into
target_type. E.g. str, unicode, int, float.
ListField also accepts a string that refers to a redisco model.
如果它们在同一个.py文件中,则不需要导入。如果它们在同一目录中的不同文件中,只需使用“import room”(假设它位于名为“import room”的文件中)房间.py'). 如果它们在不同目录中的不同文件中,则需要使用imp模块。在
然后可以用类似的方法调用它:
^{pr2}$导入模块时按此操作
或
^{pr2}$大多数ORM模型要么支持回引用(引用字段的目标模型被赋予一个指向引用对象的额外属性),要么允许您通过其他方式指定关系。在
Redisco没有我可以发现的反向引用,但是它支持字符串引用。如果传入一个字符串,它将被解释为与
__name__
属性匹配的模型名:这完全避开了进口问题。在
从^{} docstring :
code to resolve the name使用函数^{} 解析字符串,该函数只搜索
models.Model
的所有子类,匹配__name__
。在它将在验证新值或第一次检索现有值时解析名称,此时
Player
子类已经导入。在相关问题 更多 >
编程相关推荐