3
votes

I can't figure out why I'm getting this error. Please help.

Traceback (most recent call last):

File "C:\Python26\lib\site-packages\django\core\servers\basehttp.py", line 280, in run self.result = application(self.environ, self.start_response)

File "C:\Python26\lib\site-packages\django\core\servers\basehttp.py", line 674, in call return self.application(environ, start_response)

File "C:\Python26\lib\site-packages\django\core\handlers\wsgi.py", line 241, in call response = self.get_response(request)

File "C:\Python26\lib\site-packages\django\core\handlers\base.py", line 142, in get_response return self.handle_uncaught_exception(request, resolver, exc_info)

File "C:\Python26\lib\site-packages\django\core\handlers\base.py", line 166, in handle_uncaught_exception return debug.technical_500_response(request, *exc_info)

File "C:\Python26\lib\site-packages\django\views\debug.py", line 58, in technical_500_response html = reporter.get_traceback_html()

File "C:\Python26\lib\site-packages\django\views\debug.py", line 109, in get_traceback_html frames = self.get_traceback_frames()

File "C:\Python26\lib\site-packages\django\views\debug.py", line 228, in get_traceback_frames pre_context_lineno, pre_context, context_line, post_context = self._get_lines_from_file(filename, lineno, 7, loader, module_name)

File "C:\Python26\lib\site-packages\django\views\debug.py", line 209, in _get_lines_from_file context_line = source[lineno].strip('\n')

IndexError: list index out of range

can it be due to using notepad++?

4

4 Answers

6
votes

I know this answer is a bit late but it could help others :)

In my case, that was because I didn't restarted apache and the old files where used and conflicted with the new (I don't know how though). A simple apache restart fixed the problem (graceful should work too I think).

In a general way, it seems the error occurs when there is a conflict in the files and not a problem from your code. Try removing the pyc files, restarting django, apache or what is currently using your python code right now.

That worked for me.

1
votes

The source file contains Macintosh line breaks (\r) that is not supported by the djangos debug page.

See https://code.djangoproject.com/ticket/13958#comment:5

1
votes

I had a similar problem and most advice on Stackoverflow was to either a) delete *.pyc files and restart the webserver or b) check for Macintosh line breaks (for Mac users).

Both didn't help.

The error turned out to be fairly trivial. For some reason for "DEBUG=True" I was getting this error in my httpd log files, but when I changed "DEBUG=False" I started getting the actual error in the log files instead. So at least in my case this was a false error in the sense that you were not seeing the real problem because of something to do with the DEBUG=True/False switch.

In short, try DEBUG=False if it's set to True or vice versa.

0
votes

This is very odd. Get a hexdump utility and see what bytes are in the source file. Perhaps a byte order mark at the start of the file?