How to host a django project in google appspot

Do you have a project developed in Django and want to host it somewhere.? You are in right place!.  Google app engine support hosting Django projects. But you have to make some changes in your project including your Django’s ORM.

The prerequisite to do this conversion:
* installed Google Appengine SDK.
* installed django.

Google App Engine supports running any WSGI compliant application. Since Django supports this standard it is possible to build (or port existing) Django applications to run on Google App Engine.

your django project may contain the following files:     —   tells Python this is a package               —   global URL config (“URLconf”) file       —   project-specific configuration       — command-line interface for apps

‘your app directory’ contains the following files:    — same as above        — data models           — request handlers             — unit tests (optional but strongly-encouraged)

Inorder to convert your project to GAE do the following steps:

1) Create a directory for the appengine version of your project. Lets call it ‘my_gae_project’.

2) Inside the directory create a ‘app.yaml‘ file which may look like this.
3) copy this and files to your application folder. You dont need to change the content of these files.
4) copy and files from your django project to ‘my_gae_project’.

5) inside ,if there is ‘admin.autodiscover()’, remove that line.
ensure that you have given correct path for url mapping.

6) Google App Engine does not provide an SQL database so you cannot use Django’s standard Model class. So you have to convert your database models that suit to App Engine models (from google.appengine.ext import db). get help from :

This is not a big deal. you can do this with little effort, and put these new database models inside

also change the queries used inside the file to GQL.

7)Google App Engine restricts certain module imports and actions that Django tries to perform (such as creating and removing the test database). Appengine have a helper that prevents you from needing to worry about most of these differences.

ex: ‘ from django.shortcuts import get_object_or_404’. we have to remove all such import from our

8 ) create a ‘template’ directory inside current directory and place all your template files( html files) inside a template directory .

9) create a ‘static’ directory and place all your static files inside that directory.

now your directory structure look like this:


now you can deploy your django site to appengine as you are deploying your appengine project.

(The above methode worked for my url shortening project. Here is the link . Hope this will work for you too. Best wishes…)


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s