Posts

Showing posts from November, 2012

AppEngine: Intermittent DJANGO_SETTINGS_MODULE is undefined error on Django with Python 2.7 on Google App Engine

Ever since moving from webapp to Django on Python 2.7, I was plagued with the following error, albeit intermittently. Whenever, I would flush my memcache or start a new instance or run into an unhandled exception, my appengine based app wouldn't start. Logs gave me the following error, Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. I searched far and wide for a solution, looked up topics on stackoverflow. The DJANGO_SETTINGS_MODULE is a common problem for django novices like yours truly and stackoverflow had umpteen questions and answers regarding the issue, but I couldn't find the right answer. Well, let me start off with a piece of my bad code. I looked up the official documentation for pointers when I started the migration from webapp templates to purer Django templates on my appengine project. The Django Documentation on Settings page mentions the following two options to configure django settings on a project(ap

AppEngine: Python 2.7, Django Custom Template Filters without webapp, errors and more

Part of the move from Python 2.5 to Python 2.7 on Google App Engine, included moving from Django 0.96 to Django > 1.2. Another part of moving, for me atleast, included leaving webapp behind. I moved to Django 1.3, but leaving webapp is a work in progress and a part of the topic of this post. Webapp Django vs Django AppEngines's Internal Django: Webapp uses django to handle templating, however, this django version is an internal version(Let's call this "AppEngine's Internal Django"). This internal version may not support some of the features that a regular installation of Django templates would. As of SDK 1.7.3, webapp is located in google.appengine.ext.webapp and the internal django is located at google.appengine._internal.django . To use templates from webapp, one is expected to do the following from google.appengine.ext.webapp import template The webapp.template module is just a wrapper for Appengine's Internal Django templates. which are

AppEngine: Migrating from Python 2.5 to Python 2.7 on Google App Engine in simple steps

I tried moving an old app on Google App Engine from Python 2.5 to Python 2.7. Google Developers has provided a nice writeup , with all the prerequisites. However, being a noob, I found it rather difficult. The first problem being, main.app. In Python 2.5, the script is named after the filename. If you have a file called main.py which you want to be called to handle certain urls, you put the script name as main.py, under handlers in app.yaml. In the Python 2.7 runtime, app engine wants you to use the dot notation to call the appropriate "WSGI application object". So app.yaml has main.app instaed of main.py. handlers: - url: /.* script: main.app And by main.app, you are referring to the app attribute of main.py file(i.e the module called "main") I did not understand this at first, and changed the line in app.yaml to main.app and changed the name of the file main.py to main.app ImportError: No module named main  On running the application dev_appserver,

Getting Back Ubuntu after Installing Windows 8

Image
So you installed Windows 8 on your system which had a Windows 7 and Ubuntu dual boot working nicely. And now Windows 8 is running well, but you can no longer boot into Ubuntu - the boot menu is missing. Well, I did. I wrote about it too . I remember going through this every time I installed Windows. I always ended up searching "boot repair ubuntu" on google. Boot repair according ubuntu.com's  Recovering Ubuntu After Installing Windows  can be done in the following ways 1. Boot from a Ubuntu Live CD -> Install & run boot-repair -> Click on Recommended Repair and you are done. 2. Use the terminal (after logging into Ubuntu using the Live CD) and run sudo grub-install /dev/XXX where XXX is the name of the disk eg sda or sdb. You can find this out by running the following in a terminal window sudo fdisk -l 3. Using the Alternate CD to get into Rescue Mode, which then lets you run the commands given in point two above. Ubuntu Live CD does not work