Running djangoappengine

Management commands

You can directly use Django’s commands. For example, run createsuperuser to create a new admin user and runserver to start the development server.

Important: Don’t use directly. This won’t work as expected because runserver uses a customized configuration. Also, never run runserver together with other management commands at the same time. The changes won’t take effect. That’s an App Engine SDK limitation which might get fixed in a later release.

With djangoappengine you get a few extra commands:

  • remote allows you to execute a command on the production database (e.g., remote shell or remote createsuperuser)
  • deploy uploads your project to App Engine (use this instead of update)

Note that you can only use remote if your app is deployed and if you have enabled authentication via the Google Accounts API in your app settings in the App Engine Dashboard. Also, if you use a custom app.yaml you have to make sure that it contains the remote_api handler. Running ‘remote’ executes your local code, but proxies your datastore access against the remote datastore.

App Engine for Business

In order to use remote with the domain you need to add the following to the top of your

from djangoappengine.settings_base import *
DATABASES['default']['DOMAIN'] = ''

Checking whether you’re on the production server

from djangoappengine.utils import on_production_server, have_appserver

When you’re running on the production server on_production_server is True. When you’re running either the development or production server have_appserver is True and for any other command it’s False.

Zip packages

Important: Your instances will load slower when using zip packages because zipped Python files are not precompiled. Also, i18n doesn’t work with zip packages. Zipping should only be a last resort! If you hit the 3000 files limit you should better try to reduce the number of files by, e.g., deleting unused packages from Django’s “contrib” folder. Only when nothing (!) else works you should consider zip packages.

Since you can’t upload more than 10000 files on App Engine you sometimes have to create zipped packages. Luckily, djangoappengine can help you with integrating those zip packages. Simply create a “zip-packages” directory in your project folder and move your zip packages there. They’ll automatically get added to sys.path.

In order to create a zip package simply select a Python package (e.g., a Django app) and zip it. However, keep in mind that only Python modules can be loaded transparently from such a zip file. You can’t easily access templates and JavaScript files from a zip package, for example. In order to be able to access the templates you should move the templates into your global “templates” folder within your project before zipping the Python package.