title: GAE NDB AttributeError model instance has no attribute
body: <p>I have a Google App Engine NDB model called 'Bin'. <strong>I have modified the properties for 'Bin' and deleted all data entries that correspond to the older model.</strong> My goal is to query for all bins and access the attribute 'label' inside a GAE Endpoints function. However, when querying and iterating through the returned list I get <code>AttributeError: 'Bin' object has no attribute 'label'</code>, which is clearly false. Log output shows that the returned list does in fact contain two Bin objects that have an attribute called 'label'.</p>
  
  <p>What is interesting is that when I change code around the query, the code will work properly for the next run. Then it fails again.</p>
  
  <p>I have cleared the memcache, restarted the app engine launcher and deleted all entries (then adding new ones) in an attempt to remove any caching.</p>
  
  <h3>NDB Model</h3>
  
  <pre><code>class Bin(ndb.Model):
      id=ndb.IntegerProperty(required=True)
      label=ndb.StringProperty(required=True)
      items=ndb.JsonProperty()
  </code></pre>
  
  <h3>The Query</h3>
  
  <pre><code>import endpoints
  from protorpc import messages
  from protorpc import message_types
  from protorpc import remote
  from includes.models import Bin
  ...
  @endpoints.api(name='iwora', version='v1')
  class Api(remote.Service):
      @endpoints.method(message_types.VoidMessage, BinCollection,
      path='bin', http_method='GET',
      name='bin.all')
      def bin_all(self, request):
          self.user_required()
  
          namespace = namespace_manager.get_namespace()
          try:
              namespace_manager.set_namespace(self.user.active_org)
              bins = Bin.query().fetch()
              logging.info('BINS: %s' % bins)
              binsresponse = []
              for bin in bins:
                  logging.info('BIN: %s' % bin)
                  obj = {
                      'label': bin.label # error happens here
                  }
                  binsresponse.append(obj)
          finally:
              namespace_manager.set_namespace(namespace)
  
          return BinCollection(bins=binsresponse)
  ...
  </code></pre>
  
  <p>When the query is ran and I attempt to iterate through the returned bins I get the following output:</p>
  
  <blockquote>
    <p>BINS: [Bin(key=Key('Bin', 'default_bin', 'Bin', 5275456790069248),
    id=2L, items=None, label='1-1-2'), Bin(key=Key('Bin', 'default_bin',
    'Bin', 5838406743490560), id=1L, items=None, label='1-1-1')]
        BIN: Bin(key=Key('Bin', 'default_bin', 'Bin', 5275456790069248), id=2L, items=None, label='1-1-2')
        Encountered unexpected error from ProtoRPC method implementation: AttributeError ('Bin' object has no attribute 'label')
        Traceback (most recent call last):
        File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/protorpc-1.0/protorpc/wsgi/service.py",
    line 181, in protorpc_service_app
        response = method(instance, request)
        File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-
    default.bundle/Contents/Resources/google_appengine/lib/endpoints-1.0/endpoints/api_config.py",
    line 1332, in invoke_remote
        return remote_method(service_instance, request)
        File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/protorpc-1.0/protorpc/remote.py",
    line 412, in invoke_remote_method
        response = method(service_instance, request)
        File "/Users/rlfrahm/Apps/iwora/api.py", line 524, in bin_all
        'label': bin.label
        AttributeError: 'Bin' object has no attribute 'label'</p>
  </blockquote>
  
  <p>I think (as in I believe, but have not confirmed) that this only happens once I have implemented a model, added entries into the db, and then modified the model either by changing a property name or adding a new property. Even after deleting the entries I still experience this issue. I realize that this issue is not repeatable in its current state because I do not exactly know how to reproduce the error. It seems to "just happen." I have many other functions that use this same process and work just fine. Even the interactive console in the SDK Console returns correctly.</p>
  
  <p>Therefore, I am really wondering if anyone has seen this type of behavior or sees something obviously wrong with my process?</p>