django-nonrel on GAE

Experiment 01 - Django non rel First Steps

Well... djano non rel is a great project and it is quite easy to make it work with your google app engine account.


Linux/unix knowledge 
(Not much )you should know at least how to move in directories and use few basic commands like mkdir, ls -a, uname -a, ln -s  ... please read them from here . It would take 25-30 min
$ is the Linux prompt

Environment Details

$ uname -a
Linux user.localdomain #1 SMP Wed Sep 15 03:33:58 UTC 2010 i686 i686 i386 GNU/Linux


$ whereis python
python: /usr/bin/python2.6 /usr/bin/python /usr/lib/python2.6 /usr/include/python2.6 /usr/share/man/man1/python.1.gz

hg -  
$ whereis hg
hg: /usr/bin/hg /usr/share/man/man1/hg.1.gz

if not installed then use
yum install hg

install svn too it may be required in future
yum install svn

Note : yum is for fedora

App Engine SDK (python)

googleappengine SDK installed under /home/google_appengine
Download it here for your OS,  unpack it usinng gunzip or any extractor , create ~/google_appengine using
$ mkdir google_appengine
and place the extracted files in  google_appengine/
[google_app_engine ]$ python install

installed django (you can follow the process mentioned here) ,
however django nonrel team has customized it to app engine needs. please read it here.
if you want to learn it you this free book. It is quite amazing.
or purchase from amazon Complete Django The Ultimate Django Book (English and French Edition)

All django non rel apps cloned to ~/django-nonrel

[ django-nonrel]$ ls -la

you can get the hg links here

A Mobile phone and Number
It will be used to verify account creation on App engine (Verification is one time)
Please see the list of Carriers supported by Google.

Here We are ready to try your hands on django-non rel, take a break , grab a cop of coffee
and enjoy!!

Steps followed by me were :-
1. I cloned the test app  from hg clone
2. created symlinks from ~/django-nonrel directory as follows
     $ cd django-testapp
     change to /django-testapp
    [ django-testapp] $ ln -s <Yourpath/to>/django-nonrel/django django
    [ django-testapp] $ ln -s <Yourpath/to>/django-nonrel/djangoappengine/ djangoappengine
    [ django-testapp] $ ln -s <Yourpath/to>/django-nonrel/dbindexer/ dbindexer
    [ django-testapp] $ ln -s ../../django-nonrel/djangotoolbox/ djangotoolbox
     mark   is the space " "
     check if the symlinks have appeared
     [ django-testapp ]$ ls -la

3. logged in my appengine account using
    [I already have a google account ]
4. Created an app named djangotestapp - It is a very easy process
    explore yourself , or follow this tutorial on youtube

5. once an app id ( djangotestapp ) is created we need to modify few things in cloned django-testapp
    files , namely app.yaml and
    a) In app.yaml change application: ctst to application: djangotestapp
    b) (Optional ) change SITE_ID = 29 to SITE_ID = 1
6. Now use
    $ ./ createsuperuser
      and create your super user details
    $ ./ syncdb
     and sync the datastore
    $ ./ runserver --- to run the appengine server locally
     and run the server  locally and point your browser to http://localhost:8000/
     You would see It Works! Page
7. Use  $ ./ deploy
   to upload the application on appengine
8. point your browser to
   You would see It Works! Page

Now do something useful with django-nonrel and google appengine.:)

I have tried my best to cover everything in this post.
Please feel free to post questions or add details if i have missed any.


Experiment 02 - How to Enable Admin using Django non-rel  
on GAE
My reading resources are here

There are few modifications done by django non rel project team for automated deployment of your apps on GAE and they are indeed great.

$ ./ deploy  command takes care of your deployment needs. Don't use it right now :)

A ) Create super user
However remember always that your local data store is not ported to GAE data store for your application. Therefore the createsuperuser command used in Experiment 01  has not resulted in creating any super user  on your production datastore. Then what should we do ??? how to create a super user in production datastore??
Here something called remote (magic word ) comes to rescue, which uses remote api to communicate with your production app's python shell.

so any command, which is there for ./, you want to execute on your production app , just use remote before the command. For example we can create a super user for our production app using
./ remote createsuperuser , So Create the super user !!.

Quick Fix for admin logout error, which you are bound to encounter, till it is fixed for later release :) of non rel

access your production app's remote python shell and follow below mentioned steps

$./ remote shell - It will open remote python shell on your GAE. I was quite happy to see remote python shell >>_

  >> from django.contrib.sites.models import Site
  >> import settings
  >> Site(id=settings.SITE_ID,domain="", name="djangotestapp")
fix it on local as well ,
just replace the 03rd line with below line after logging in local shell using $./ shell
  >> Site(id=settings.SITE_ID, domain="localhost", name="djangotestapp")

  You can validate using the following line on both local and remote python shell
 >> Site.objects.all( )
You would see something like
[] -- on remote 

[local host] -- on local

B ) Configure Django Admin App
   (on the local app)
Django admin app is shipped with your django distribution it does not need seperate installation, you just need to enable it
   1. Change your UrlConf
   Add these lines for imports

   from django.views.generic.simple import direct_to_template

   from django.contrib import admin


   Add the url pattern

    urlpatterns = patterns('',
        ('^_ah/warmup$', 'djangoappengine.views.warmup'),
        (r'^admin/', include(, # Enabling Admin 
        ('^$', direct_to_template,{'template': 'home.html'}),

  2. Modify your  INSTALLED_APPS
                         'django.contrib.admin', # uncommented the line

C) Sync the local db
   $./ syncdb
       You can run ./ validate -- to check if all admin models are working fine before syncing db

D) Check it on local by running the server
    $./ runserver
    point your browser to http://localhost:8000/admin
    you will see admin interface login page (i hope you remember your super user , userid and password :)

That's it , now use
$ ./ deploy
wait for the update to finish ... finish your tea if you left it midway :)

After the update point your browser to http://<Urappid>
You should be able to see the same admin login page as you saw on local

Enjoy!! Now you can use admin as you want !!


  1. Very informative, thank you.

  2. thanks michael.. :) you are the first one to comment though..

  3. and for me don't work -( all the time tells "Please enter a correct username and password."... on

  4. Hi Bogdan,

    Please create a super user for your appengine app using
    python remote createsuperuser , choose the default user or give a custom name and password.. remember if you are using django-testapp created by allbuttonspressed team , take care of adminlogout error too mentioned at Then you will able to access the django admin interface using

  5. This comment has been removed by the author.

  6. When i change the contents in on the webpage it gives an identation error/at admin
    unexpected indent (, line 4)

  7. I've got this error while deploying

    I'm using GAE+ django nonrel

    Creating tables ...
    Installing custom SQL ...
    Installing indexes ...
    No fixtures found.
    Exception exceptions.AttributeError: "'NoneType' object has no attribute 'mkstemp'" in > ignored

  8. Thank you very much for the info. I had tried everything to create a superuser in Admin django but nothing seems to work:

    python remote createsuperuser --username... Finally did it.

  9. Anonymous12:35 AM

    jitendra, I uploaded django-nonrel along with the app. But now I have very little space for uploading my code files. I amm allowed 3000 files and most of space is taken up by django-nonrel. Is there any way that we could work it out by not including django-nonrel in the project?

  10. Anonymous9:46 AM

    there is an error when i creating suepruser in local ..

    google.appengine.api.yaml_errors.EventListenerYAMLError: mapping values are not allowed here
    in "workspace/firstpoochedi/", line 3, column 4


Please Leave your comments