--
--Guido van Rossum (python.org/~guido)
buyer = db.ReferenceProperty(auth_models.User)
File "/media/Lexar/bnano/google/appengine/ext/db/__init__.py", line
3506, in __init__
raise KindError('reference_class must be Model or _SELF_REFERENCE')
KindError: reference_class must be Model or _SELF_REFERENCE
Could I somehow use a db.Key instead to create the reference? Or
create a reference the other way with a list for every user what
products the user bought.
Or just resort to the using the id instead of the key:
buyer_id = db.IntegerProperty()
?
Using the last way I can know the user saving it this way
order.buyer_id = int(user.key.id())
Thanks for the help
You would have to set it using userinstance.key.to_old_key(), and to
get it you would have to get the key from the reference property using
get_value_for_datastore. This returns a db.Key, you can convert that
to an ndb Key using ndb.model.Key.from_old_key(oldkey).
But all this seems really awkward. Maybe you can store the key as a
string in your old db model?
class Order(db.Model):
'''a webshop transaction'''
items = db.ListProperty(db.Key)
amounts = db.ListProperty(int)
buyer_id = db.IntegerProperty()
total = db.StringProperty()
I think I also could rewrite the above model to an NDB model and then
I could use the keyproperty, but it's fine as it is now.
Cheers, Niklas