Sunday, February 24, 2013

Up-to-date guide for running Django (using django-nonrel) on Google App Engine (2013)

  • First install Google App Engine using AUR . If you don't use Arch by now, it's about time :P. Anyways, use your package manager to install GAE.
    This will install Google App Engine in  /opt/google-appengine-python/ directory. The project that we're gonna clone wants google-appengine to be present in /usr/local/google_appengine
    sudo ln -s /opt/google-appengine-python /usr/local/google_appengine
    
  • Get our shit ready.
  • $cd django_on_gae;            #Our Project 'super' directory
    $git clone https://github.com/django-nonrel/django-nonrel
    $git clone https://github.com/django-nonrel/djangoappengine
    $git clone https://github.com/django-nonrel/djangotoolbox
    $hg clone https://bitbucket.org/twanschik/django-autoload
    $git clone https://github.com/django-nonrel/django-dbindexer
    $git clone https://github.com/django-nonrel/django-testapp #This is our test app
    
    
    Copy the relevant folders to the project directory.
    $cd django-testapp
    $cp -rv ../django-nonrel/django .
    $cp -rv ../djangotoolbox/djangotoolbox .
    $cp -rv ../django-autoload/autoload .
    $cp -rv ../django-dbindexer/dbindexer .
    $cp -rv ../djangoappengine .
    
  • Create a app on http://appengine.google.com/. When you are done, you'll get a page saying: 
    The application will use hello-world-shadyabhi as an identifier. This identifier belongs in your application's configuration as well. Note that this identifier cannot be changed. Learn more
    
    Open app.yaml fil and edit the application: accordingly.
  •  Finally, 
    $./manage.py createsuperuser
    WARNING  2013-02-24 05:05:42,848 dev_appserver.py:3578] The datastore file stub is deprecated, and
    will stop being the default in a future release.
    Append the --use_sqlite flag to use the new SQLite stub.
    
    You can port your existing data using the --port_sqlite_data flag or
    purge your previous test data with --clear_datastore.
    
    WARNING  2013-02-24 05:05:42,848 datastore_file_stub.py:528] Could not read datastore data from /home/shadyabhi/github/django_on_gae/django-testapp/.gaedata/datastore
    WARNING  2013-02-24 05:05:42,850 simple_search_stub.py:975] Could not read search indexes from /tmp/dev_appserver.searchindexes
    Username (Leave blank to use 'shadyabhi'): root
    E-mail address: myemail@gmail.com
    Password: 
    Password (again): 
    Superuser created successfully.
    
    $./manage.py syncdb
    WARNING  2013-02-24 05:06:27,198 dev_appserver.py:3578] The datastore file stub is deprecated, and
    will stop being the default in a future release.
    Append the --use_sqlite flag to use the new SQLite stub.
    
    You can port your existing data using the --port_sqlite_data flag or
    purge your previous test data with --clear_datastore.
    
    WARNING  2013-02-24 05:06:27,200 simple_search_stub.py:975] Could not read search indexes from /tmp/dev_appserver.searchindexes
    Creating tables ...
    Installing custom SQL ...
    Installing indexes ...
    No fixtures found.
    
    $./manage.py runserver #And everything should work
    


  • For password-less deploys: 
    /usr/bin/appcfg.py --oauth2 update ./
    
    A new tab will open and that'll require you to click allow access.  
  • From now on, if you do any changes, you can deploy the app by executing the above command again, ie: 
    /usr/bin/appcfg.py --oauth2 update ./ 
    That's it for now.

    No comments:

    Post a Comment