Chakradar Raju
Chakradar Raju

Reputation: 2811

How to deploy Django application in Google App Engine?

I'm trying to start a Django application in GAE and bumping into error after error.

I tried this example: https://github.com/GoogleCloudPlatform/appengine-django-skeleton, and got:

ImportError: No module named djangoappengine

I tried this example: https://code.google.com/p/google-app-engine-samples/downloads/detail?name=django_example_20080409.tar.gz, and got:

ImportError: No module named django.core.handlers.wsgi

I tried starting a Django project and making it run in GAE, many different errors there.

Is there a simple example? I ready to update, here are current version:

Python version: 2.7.5

Django version: 1.6.5

GAE version: 1.9.17

Upvotes: 2

Views: 590

Answers (2)

GAEfan
GAEfan

Reputation: 11360

djangoappengine is not part of normal Django, and not part of the Django that GAE uses. You are mixing djangos. To use djangoappengine, you will want to use a certain branch of Django that is set up for non-relational, non-sql datastores, like the main GAE datastore. You will want to use django non-rel, which ships with a customized version of Django (1.6 in beta, but 1.5.5 production version) that works well on GAE. Here are the packages you'll want to install, per the methods Paul C outlined above:

http://djangoappengine.readthedocs.org/en/latest/installation.html

This way, you don't have to use the cloud-sql relational datastore, and can use the regular GAE non-relational datastore that works so elegantly using the db and ndb methods.

Upvotes: 1

Paul Collingwood
Paul Collingwood

Reputation: 9116

You can either upload Django with your application, so it can be imported, or use the provided version. Try putting it in the same directory as your app.yaml to upload it.

Add this to your app.yaml to access the provided version:

libraries:
- name: django
  version: "1.5"

And you will be able to import Django without uploading it. If you want a specific version that is not provided you'll have to include it in your application.

According to this link, where you can also read about how to include imports in your application, the latest version of Django GAE provides is 1.5 https://cloud.google.com/appengine/docs/python/tools/libraries27

So if you want 1.6.5 you'll have to upload it along with your application. You can read about that here: How to include third party Python libraries in Google App Engine?

And see this page for specific instructions for Django on GAE: https://cloud.google.com/appengine/docs/python/cloud-sql/django

Upvotes: 3

Related Questions