我在 GAE 中使用“递归”的 ndb 对数据结构进行了建模,因为我希望它在其中存储相同结构化类型的实例。从概念上讲,
class Person(ndb.Model):
name = ndb.StringProperty()
friend = ndb.StructuredProperty(Person)
我收到以下错误:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 84, in LoadObject
obj = __import__(path[0])
File "C:\Users\Rusty\Documents\GitHub\AutoAddDrop\autoadddrop.py", line 2, in <module>
import models
File "C:\Users\Rusty\Documents\GitHub\AutoAddDrop\models.py", line 100, in <module>
class Bid(ndb.Model):
File "C:\Users\Rusty\Documents\GitHub\AutoAddDrop\models.py", line 123, in Bid
outbid_by = ndb.StructuredProperty(Bid) #Winning Bid
NameError: name 'Bid' is not defined
这是中的课程models.py
:
class Bid(ndb.Model):
user_id = ndb.StringProperty()
league_id = ndb.StringProperty()
sport = ndb.StringProperty()
bid_amount = ndb.IntegerProperty()
timestamp = ndb.DateTimeProperty()
status = ndb.StringProperty()
target_player_id = ndb.StringProperty()
target_player_name = ndb.StringProperty()
target_player_team = ndb.StringProperty()
target_player_position = ndb.StringProperty()
add_player_id = ndb.StringProperty()
add_player_name = ndb.StringProperty()
add_player_team = ndb.StringProperty()
add_player_position = ndb.StringProperty()
drop_player_id = ndb.StringProperty()
drop_player_name = ndb.StringProperty()
drop_player_team = ndb.StringProperty()
drop_player_position = ndb.StringProperty()
bid_type = ndb.StringProperty()
bid_direction = ndb.StringProperty()
target_value = ndb.FloatProperty()
transaction_timestamp = ndb.DateTimeProperty()
outbid_by = ndb.StructuredProperty(Bid) #Winning Bid
outbid_by_key = ndb.KeyProperty(Bid) #key of winning bid
cbs_add_transaction = ndb.JsonProperty()
transaction_reason = ndb.StringProperty()