python - App engine ndb. Query model based on Reference Property -
I have some problems in querying the object while using NDB in the AppEngine framework for I It is very new and I think I understand some important concepts wrong.
Here's what I got:
I have my model code teacher (ndb.model) from the The user coming in the form of this function comes as follows: < Pre> However, I get the following error: I would like to know where my mistake Land and example of an app using Andibi and Vebpp 2 Eighth system will be very useful. thanks all to: Although a structured property can be duplicated and a structured property may include another structured property, be careful: if one is in a structured asset, only one of them can be repeated. The error is happening because the teacher User is a structured property that includes teachers. The user .auth_ids, which is the repetitive Structured Sprouts. I recommend doing this: Store a reference for the user. It will work for your example above, however, it also means that you can not query any user properties, such as And you will ask: I hope it helps.
def _findTeacher (self, user): t = teacher. Curious (teacher.use == user). Fetch (1) If T: Returns T [0] Else: return Anyone
user_session = self.auth.get_user_by_session () user = Self.auth.store.user_model.get_by_auth_token (user_session ['user_id'], user_session ['token']) [0]
BadFilterError: invalid filter: non-empty repetitive property can not query for auth_ids
Edit (solution):
class teacher (ndb.model): user = ndb.KeyProperty ( User) Ranking = ndb.FloatProperty (required = true)
Teacher.User.name == 'bob' .
t = teacher.query (teacher.user == user.key) .fetch (1)
Comments
Post a Comment