I just got a new job working for a website and I am trying to get a development server working on my work computer. I’ve copied all the configurations and what not and I am still getting errors.
When I try to display the front page I get
list index out of range
The exception is being raised
python2.6/site-packages/Django-1.3-py2.6.egg/django/db/models/query.py in __getitem__, line 190
Here is the traceback information.
Environment:
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.3
Python Version: 2.6.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.sites',
'django.contrib.flatpages',
'django.contrib.markup',
'south',
'radio.frontend',
'radio.events',
'radio.library',
'radio.logs',
'radio.station',
'radio.staff',
'gravatar',
'djcelery',
'gunicorn']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
Traceback:
File "/home/wluw/wluw/lib/python2.6/site-packages/Django-1.3-py2.6.egg/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/home/wluw/wluw/wluw/radio/frontend/views.py" in home
20. schedule = Schedule.objects.get_current_schedule(now)
File "/home/wluw/wluw/wluw/radio/station/managers.py" in get_current_schedule
64. return results[0]
File "/home/wluw/wluw/lib/python2.6/site-packages/Django-1.3-py2.6.egg/django/db/models/query.py" in __getitem__
190. return list(qs)[0]
Exception Type: IndexError at /
Exception Value: list index out of range
Here is some of the code I’ve got that is adding to the error
class ScheduleManager(models.Manager):
def get_current_schedule(self, when):
results = self.filter(start_date__lte=when, end_date__gte=when).order_by('-start_date')
#try:
#if(results[0]):
return results[0]
#else:
# return "null"
#
#except IndexError:
#raise self.model.DoesNotExist
def get_current_schedule_or_404(self, when):
try:
return self.get_current_schedule(when)
except self.model.DoesNotExist:
raise Http404
I am still not to familiar with python so any suggestions of where to fiddle around with the code would be great.
I have a feeling it has something to do with database not being populated with data, but I added in stuff and I still get the error.
Thanks for any help you may give.
If you need more info just let me know.
The traceback tells you what the problem is. The homepage is trying to display the top Schedule – but you don’t have any in your database. You need to create some.