Tutorial part 4 IndexError

32 views
Skip to first unread message

jonathan_ou

unread,
Apr 13, 2007, 2:12:59 AM4/13/07
to Django users
I am using python 2.5 with django 0.96 rev 5005 using mysql database.
When I try to cast a vote via web forms in part 4 of the tutorial, I
get the following error after I select a choice and submit the form:

Traceback (most recent call last):

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/servers/basehttp.py", line 272, in
run
self.result = application(self.environ, self.start_response)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/servers/basehttp.py", line 614, in
__call__
return self.application(environ, start_response)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/handlers/wsgi.py", line 189, in
__call__
response = self.get_response(request)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/handlers/base.py", line 111, in
get_response
return debug.technical_500_response(request, *sys.exc_info())

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/views/debug.py", line 96, in
technical_500_response
pre_context_lineno, pre_context, context_line, post_context =
_get_lines_from_file(filename, lineno, 7)

File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/views/debug.py", line 175, in
_get_lines_from_file
context_line = source[lineno].strip('\n')

IndexError: list index out of range
------------------------------------------------------------------------------------------

The code and template html is directly copied from the tutorial
website (copy and paste). Yet for some reason this error continues to
pop up and django's own debug html page doesn't even load. The error
messages are entirely in plain text.

Does anyone know how to solve this problem?

Niels

unread,
Apr 13, 2007, 8:27:02 AM4/13/07
to Django users
I smell the sense of an end-of-line convention problem in django's
debug view. Could it be your sourcefile uses '\r' for end of line
where django expects a '\n' ??

> ---------------------------------------------------------------------------­---------------

jonathan_ou

unread,
Apr 13, 2007, 11:50:19 AM4/13/07
to Django users
Thanks! That was exactly it. I was using Mac OSX to develop and they
use a different line ending character than Unix. Everything works
correctly now.

Thanks again.

Reply all
Reply to author
Forward
0 new messages