0

Same code, in production don't work while in development yes.

models:

class Comput(ndb.Model):
    @staticmethod
    def membership(user):
        q = ndb.gql("SELECT * FROM Members WHERE member = :1", user)
        result = q.fetch()
        return [m.comput.get() for m in result]
        #return [m.comput.get() for m in q] #same issue (dev yes, prod no)

class Members(ndb.Model):
    comput = ndb.KeyProperty(kind=Comput)
    member = ndb.UserProperty()

handler:

comput_list = Comput.membership(users.get_current_user())

template:

{% for comput in comput_list %}
    <tr onclick="location.href='/comput?id={$ comput.key.id() $}'">

Traceback (only in production):

UndefinedError: 'None' has no attribute 'key'

This appears even when comput_list have entities.

update: No autogenerate index for Members, I tried to add manually but nothing changes

Evan Plaice
  • 13,944
  • 6
  • 76
  • 94
Gianni Di Noia
  • 1,577
  • 10
  • 25

1 Answers1

1

Looks like one of your Members objects has None for its comput property. I would use the production data viewer (or add a log statements) to find which member it is.

Jesse Rusak
  • 56,530
  • 12
  • 101
  • 102
  • Yes! The function that delete the Comput entities don't delete also the referenced Members entities. Then I had a Members entity with a comput property that link to a missed Comput entity. – Gianni Di Noia Jul 01 '12 at 13:19