マニュアルには、db.allocate_id_range の使用例がありません。私はいくつかのコードを試してみましたが、特に ndb expando モデルである webapp2:s User モデルで失敗しました。私がやりたいことは、選択した ID 番号を持つ User エンティティを作成するだけなので、db.allocate_id_range を使用しようとしましたが、機能していません。
BadArgumentError: Expected an instance or iterable of (<class 'google.appengine.
ext.db.Model'>, <class 'google.appengine.api.datastore_types.Key'>, <type 'bases
tring'>); received User<address=StringProperty('address'), auth_ids=StringProper
ty('auth_ids', repeated=True), created=DateTimeProperty('created', auto_now_add=
True), firstname=StringProperty('firstname'), lastname=StringProperty('lastname'
), notify=BooleanProperty('notify', default=False), notify_sms=BooleanProperty('
notify_sms', default=False), password=StringProperty('password'), phone_cell=Str
ingProperty('phone_cell'), registered=BooleanProperty('registered', default=Fals
e), sponsor=KeyProperty('sponsor'), updated=DateTimeProperty('updated', auto_now
=True)> (a MetaModel).
私がやろうとしている方法はこのようなものです
first_batch = db.allocate_id_range(User, 3001, 3001) #try allocate ID 3001
私はそれを間違っていますか?モデル名を引用符で囲んでみましたが、それもうまくいきませんでした。これをどのように行う必要がありますか?アドバイスをありがとう。