Upgrading Django

I was working through some examples in the Django Book and got the following error message;

‘function’ object has no attribute ‘rindex’

Searching the Django wiki http://code.djangoproject.com/wiki/IrcFAQ#WeirdError1  suggests that this is a telltale sign that I am working through a Django Book example with a version of Django that is older than the latest build.

Turns out I have version 0.95. The latest if 0.96, so I decided to upgrade.

Download, gunzip, tar, and python setup.py install.

Oops! sudo python setup.py install.

Restarting my server still show 0.95 is the default. At this point I am hoping it is easy to upgrade my app to the new version.

Turns out my path is still pointing at the 0.95 directory. I am using Bash on OS X 10.3 so I cracked open ~/.profile to edit the Path statement it now reads;

PATH=~/dev/lib/Django-0.96/django/bin:/usr/local/pgsql/bin:${PATH}

Arghh! Still 0.95.

So it looks like

django-admin.py runserver

does call into 0.96 but it is picking up 0.95 along the way in the python libraries in

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/Django-0.95-py2.5.egg/django/conf/__init__.py

So I moved the Django-0.95… directory so that hopefully the 0.96 version would be picked up. It looks like that worked. Only now I get the following error.

EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined.

It is beginning to look like the setup.py install didn’t do any of the things it should have.

I just found the answer to my problems at http://forum.webfaction.com/viewtopic.php?id=368

In my directory with settings.py I execute

export DJANGO_SETTINGS_MODULE=settings

Now,

python manage.py runserver

Does fire up 0.96.

Doubling back on my other changes, if I put the 0.95 dir back in the python lib path, it supersedes the 0.96 version so I am keeping that out.

Now to check my original problem.

Now I am getting a NameError

name ‘views’ is not defined

Typo!!! in my urlpattern I had

(r’^mysite/count_list’, views.current_datetime),

It is now

(r’^mysite/count_list’, current_datetime),

And it all works now!

Leave a comment