Sriram
Sriram

Reputation: 838

How do I set the Application Id in appengine?

I'm using Django along with appengine. When I try to save a record, I'm getting the error "app_id must not be empty". The application name has been set in app.yaml. I also added os.environ['APPLICATION_ID'] = 'test' in main.py. However, I continue to get the same error.

Upvotes: 1

Views: 2306

Answers (2)

Filippo Vitale
Filippo Vitale

Reputation: 8103

When I try to save a record, I'm getting the error "app_id must not be empty".

When I'm using appengine as "standalone" e.g. (unit testing) in order to fix the "app_id must not be empty" error I always execute:

app_id = 'XXXXXX'
os.environ['APPLICATION_ID'] = app_id
datastore_path = os.path.join(tempfile.gettempdir(),'dev_appserver.datastore')
history_path = os.path.join(tempfile.gettempdir(),'dev_appserver.datastore.history')
require_indexes = False
apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap()
datastore = datastore_file_stub.DatastoreFileStub(app_id, datastore_path, history_path, require_indexes=require_indexes)
apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', datastore)

just before my code that use the Google App Engine datastore.

If you run the appserver locally you shouldn't need this code because all the magic is made by the framework reading the app.yaml file

Upvotes: 1

mckoss
mckoss

Reputation: 7014

I haven't seen your error before. Note that you can't use the native Django database functions without using the "Django Helper" application:

http://code.google.com/appengine/articles/appengine_helper_for_django.html

You do not need to use Django Helper if you are only using parts of Django (but using native App Engine Models for storage):

http://code.google.com/appengine/docs/python/datastore/overview.html

Upvotes: 0

Related Questions