On thursday morning I set out to learn python and by saturday morning I had read through the official tutorial on the python website as well as gone on numerous side trips on additional references. Blog posts are still paying catch up. You will not find me writing a killer python app in a few days but I can read and understand python code pretty well by now. It’s essentially a reproduction of my learn Ruby in 48 Hours project.

Now to set my sites on Django. Should I look at Zope instead? This was supposed to be a PHP killer about a decade ago but seems to have completely fallen by the way side, so probably not. Most python developers today might not even have heard the name. So let’s get started with a guide from WebMonkey

    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '/home/ec2-user/projects/djangoblog/djangoblog.db',                    # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.


That is not how the webmonkey guide says the file should be, but you should use my version if you don’t want to see the following error:

Traceback (most recent call last): File "", line 10, in execute_from_command_line(sys.argv) File "/usr/lib/python2.6/site-packages/django/core/management/", line 442, in execute_from_command_line utility.execute() File "/usr/lib/python2.6/site-packages/django/core/management/", line 381, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.6/site-packages/django/core/management/", line 195, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/lib/python2.6/site-packages/django/core/management/", line 231, in execute output = self.handle(*args, **options) File "/usr/lib/python2.6/site-packages/django/core/management/", line 371, in handle return self.handle_noargs(**options) File "/usr/lib/python2.6/site-packages/django/core/management/commands/", line 57, in handle_noargs cursor = connection.cursor() File "/usr/lib/python2.6/site-packages/django/db/backends/dummy/", line 15, in complain raise ImproperlyConfigured("settings.DATABASES is improperly configured. " django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

The django version on this machine (a centos 5.4 AMI) was 1.5 and python was 2.6.6. A lot newer than what the author of the webmonkey article probably used.  Yeah, Python and Ruby doesn’t care too much about backward compatibility. The next bit produced another error but you I will spare you the lengthy stacktrace.

“'Adminsite' object has no attribute 'root'”

Another problem related to old age. Two years seems to be a very long time in the world of Django and RoR. Compare this with PHP tutorials written in the last millenium which are still valid today. The solution as listed on stackoverflow is an easy one;

Your url for admin should be:
url(r’^admin/’, include(
not (r’^admin/(.*)’,
– it’s for Django 1.0. For Django 1.3 it wouldn’t work.

Predictably, that is not the end of the story. The next step, adding the django-tagging modules causes another exception. Once again you will be spared the full error dump.

ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined

Unfortunately this is where I got stuck. There are plenty of solutions posted mostly to do with setting an DJANGO_SETTINGS_MODULE environment variable but none of it worked for me. Looks like you either need to find a new tutorial or downgrade your Django installation to an older version.

I am either going to have to find a different tutorial or downgrade to an older version python and/or django. Oh by the way, my Learn RoR in a day project also lies abandoned.

May 3rd, 2012 | Posted in Uncategorized
No comments yet.

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>