Chiya, I asked a question earlier regarding the use of keys, which were answered.
However, now I'm wondering how to create and use keys for my models, my iPhone guy told me that we need INTs to store in the database. I got Python code working with Keys, and now I may have to step back.
I would be happy to hear your opinion on how to create key names and automatically generate identifiers that my iPhone application can use without any major changes.
Here are my models:
class User(db.Model):
id = db.StringProperty()
name = db.StringProperty()
image = db.BlobProperty(default=None)
class Book(db.Model):
image = db.BlobProperty()
date_added = db.DateTimeProperty(auto_now_add=True)
is_active = db.BooleanProperty(default=True)
class BookUser(db.Model):
book = db.ReferenceProperty(Book)
user = db.ReferenceProperty(User)
is_active = db.BooleanProperty(default=True)
().
, BookUser, , . iPhone . , , , iPhone " ":)
?
user_id = 1
user = User.get_by_key_name(user_id)
user_key = user.key().name()
book = Book.all().filter('is_active =', True).get()
book_key = book.key().name()
bookuser_key_name = "%s:%s" % (str(book_key), str(user_key))
bookuser = BookUser.get_or_insert(bookuser_key_name)
bookuser.card = card
bookuser.user = user
bookuser.put()