GetItDone
GetItDone

Reputation: 576

Django server error

I can't seem to figure out why I started to get the server error listed all of a sudden. Any ideas?

The full traceback:

Traceback (most recent call last):
  File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 67, in __call__
    return self.application(environ, start_response)
  File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 179, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 221, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python27\lib\site-packages\django\views\debug.py", line 66, in technical_500_response
    html = reporter.get_traceback_html()
  File "C:\Python27\lib\site-packages\django\views\debug.py", line 286, in get_traceback_html
    c = Context(self.get_traceback_data())
  File "C:\Python27\lib\site-packages\django\views\debug.py", line 244, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python27\lib\site-packages\django\views\debug.py", line 390, 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:\Python27\lib\site-packages\django\views\debug.py", line 371, in _get_lines_from_file
    context_line = source[lineno].strip('\n')
IndexError: list index out of range
[01/Nov/2012 10:46:55] "GET /home HTTP/1.1" 500 59
Traceback (most recent call last):
  File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 67, in __call__
    return self.application(environ, start_response)
  File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 241, in __call__
    response = self.get_response(request)
  File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 179, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 221, in handle_uncaught_exception
    return debug.technical_500_response(request, *exc_info)
  File "C:\Python27\lib\site-packages\django\views\debug.py", line 66, in technical_500_response
    html = reporter.get_traceback_html()
  File "C:\Python27\lib\site-packages\django\views\debug.py", line 286, in get_traceback_html
    c = Context(self.get_traceback_data())
  File "C:\Python27\lib\site-packages\django\views\debug.py", line 244, in get_traceback_data
    frames = self.get_traceback_frames()
  File "C:\Python27\lib\site-packages\django\views\debug.py", line 390, 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:\Python27\lib\site-packages\django\views\debug.py", line 371, in _get_lines_from_file
    context_line = source[lineno].strip('\n')
IndexError: list index out of range

Upvotes: 1

Views: 748

Answers (2)

GetItDone
GetItDone

Reputation: 576

So I finally got it figured out... I set debug = False, just to see what would happen because the traceback included debug.py. Anyway, I'm still a beginner, and don't even know if this really even makes sense, but after I changed debug = False in my settings, I got a new traceback which informed me that one of my CHOICES in one of my forms didn't match. I don't understand at all why this would crash the development server, but I fixed it and now it works. So to clarify what the problem was:

#forms.py

PAYMENT_PLAN = {
    ('A', 'A'),
    ('B', 'B'),
    ('C', 'C'),
}

class SurveyForm(ModelForm):
    class Meta:
        model = Survey
        widgets = {
            'pay_plan': Select(choices=PAY_PLAN),
            ...
        }

So, the new traceback with debug=False stated:

NameError: name 'PAY_PLAN' is not defined

So anyway, I fixed that, and now it works again. So if someone runs into the same issue, try turning debug=False to see what happens and maybe it will help you figure it out.

Upvotes: 1

jro
jro

Reputation: 9484

I can't tell if you are using a webserver of any kind, or just the development server. In any case, shutdown any server you are using, and clean up all of the .pyc files in your project. Restart the webserver, and you should be good to go.

Most commonly there is a mismatch between the compiled files and the sources. As to why this happens, no clue, but it has happened to me in the past: doing the above resolved it for me.

Upvotes: 3

Related Questions