I am new to Python and am currently working on my first Google App Engine application. In my program, I have an Inbox database model that contains row restrictions such as to_user, from_user, title, content, etc. When a user logs into my application, I want to be able to count the number of messages that were sent to him / her, so I can display it as "New Messages (x)". I feel that I am currently using work because I cannot find a better way.
user = users.get_current_user()
inbox = Inbox.gql('WHERE to_user = :to_user', to_user=user.nickname())
count = 0
for note in inbox:
count = count+1
I tried using len (inbox) but that gave me an error. Thank you for your time.
source
share