Friday 11 July 2014

appengine - django with non rel database

Hello friends, today I am going to tell how to run django on appengine with non relational database.
I am assuming that you have installed appengine sdk, python and django.
I am using following versions,

Python – 2.7
Django- 1.5
Appengine – 1.9.6

Download following packages ,
Now create django project named testapp,
Now unzip all the above packages and paste in your django project , now your project should like this ,

Now download django-testapp from https://github.com/django-nonrel/django-testapp and unzip it elsewhere, and copy manage.py file from this to our projct root directory.It will prompt you to replace with previous one ? click on yes. Now copy settings.py , indexes.py  and app.yaml file from  this folder and and paste it to our root directory ,

Now our project  under directory testapp looks like ,
Now just cut and paste urls.py from testapp app.  And finally our project looks like ,

Now run django project using runserver command locally , you should see homepage for django project.

Now edit views.py from testapp add following contents ,

from django.http import HttpResponse
def home(request):
    return HttpResponse("Hello World")

and modify urls.py file to the following contents,

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    url(r'^$', 'testapp.views.home', name='home'),
)


Uploading it to appengine ,

First go to appengine.google.com and create a new application by specifying applicaition name and title.And click on create application , now edit your app.yaml file and edit application name , make sure that name application created is same as name in app.yaml.
Now final step ,Run following command and provide valid creadentials ,
python manage.py deploy
and follow instrucions.
Now see you app online <appname>.appspot.com

No comments:

Post a Comment