Hi again, I am trying to deploy a search function to my website. It works well in the development environment, but in the production side I get the error message below (and my codes). I appreciate a lot if someone could help me again. I'm using PythonAnywhere in production, if that matters.
Best regards, Mikko *Error:* 2018-10-19 13:13:13,629: Error running WSGI application 2018-10-19 13:13:13,630: IndexError: list index out of range 2018-10-19 13:13:13,630: File "/usr/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 142, in __call__ 2018-10-19 13:13:13,630: response = self.get_response(request) 2018-10-19 13:13:13,630: 2018-10-19 13:13:13,630: File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 78, in get_response 2018-10-19 13:13:13,631: response = self._middleware_chain(request) 2018-10-19 13:13:13,631: 2018-10-19 13:13:13,631: File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner 2018-10-19 13:13:13,631: response = response_for_exception(request, exc) 2018-10-19 13:13:13,631: 2018-10-19 13:13:13,631: File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception 2018-10-19 13:13:13,631: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info()) 2018-10-19 13:13:13,631: 2018-10-19 13:13:13,631: File "/usr/lib/python3.6/site-packages/django/core/handlers/exception.py", line 125, in handle_uncaught_exception 2018-10-19 13:13:13,632: return debug.technical_500_response(request, *exc_info) 2018-10-19 13:13:13,632: 2018-10-19 13:13:13,632: File "/usr/lib/python3.6/site-packages/django/views/debug.py", line 94, in technical_500_response 2018-10-19 13:13:13,632: html = reporter.get_traceback_html() 2018-10-19 13:13:13,632: 2018-10-19 13:13:13,632: File "/usr/lib/python3.6/site-packages/django/views/debug.py", line 333, in get_traceback_html 2018-10-19 13:13:13,632: c = Context(self.get_traceback_data(), use_l10n=False) 2018-10-19 13:13:13,632: 2018-10-19 13:13:13,632: File "/usr/lib/python3.6/site-packages/django/views/debug.py", line 264, in get_traceback_data 2018-10-19 13:13:13,632: frames = self.get_traceback_frames() 2018-10-19 13:13:13,633: 2018-10-19 13:13:13,633: File "/usr/lib/python3.6/site-packages/django/views/debug.py", line 422, in get_traceback_frames 2018-10-19 13:13:13,633: filename, lineno, 7, loader, module_name, 2018-10-19 13:13:13,633: 2018-10-19 13:13:13,633: File "/usr/lib/python3.6/site-packages/django/views/debug.py", line 383, in _get_lines_from_file 2018-10-19 13:13:13,633: context_line = source[lineno] *urls.py* from django.urls import path from . import views app_name = 'news' urlpatterns = [ path('', views.Home, name='home'), path('all/', views.All_news, name='all'), path('world/', views.World, name='world'), path('sport/', views.Sport, name='sport'), path('economy/', views.Business, name='economy'), path('politics/', views.Politics, name='politics'), path('scitech/', views.SciTech, name='scitech'), path('search/', views.Search, name='search'), ] *views.py:* from django.db.models import Q def Search(request): query = request.GET.get('q') results = news.objects.filter(Q(title__icontains=query) | Q(publisher__icontains=query)).order_by('-created') args = {'results': results} return render(request, "news/search.html", args) *base.html:* <form method="GET" action="{% url 'news:search' %}" class="form-inline"> <input class="form-control mr-sm-2" type="search" name="q" value="{{request.GET.q}}" placeholder="search" aria-label="Search"> <button class="btn btn-light my-sm-0" type="submit"> Search </button> </form> *search.html:* {% for news in results %} <h4> <a href="{{ news.url }}" target="_blank">{{ news.title }}</a> </h4> <p> <a href="{{ news.homepage }}" target="_blank">{{ news.publisher }}</a> | {{ news.subsection2 }} | {{ news.published }} </p> <hr class="m-y-md" /> {% endfor %} -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGD0jjJPcnpX3B_AQ9EiMzae-G_jecndaUqxdfK6f1wD1Oyk%3DA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.