title: Python DJANGO Error IndexError at / list index out of range
body: <p>I am new to python. Trying to create a simple application using django. I am facing the index out of range exception with this line "ndim = mobjs[0].ndim". Any help would be highly appreciated   </p>
  
  <p>Error    </p>
  
  <pre><code>\File "/home/anthra/server_movierecsys/books_recsys_app/views.py", line 66, in home
  ndim = mobjs[0].ndim
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def home(request):
  context={}
  if request.method == 'POST':
      post_data = request.POST
      data = {}
      data = post_data.get('data', None)
      if data:
          return redirect('%s?%s' % (reverse('books_recsys_app.views.home'),
                              urllib.urlencode({'q': data})))
  elif request.method == 'GET':
      get_data = request.GET
      data = get_data.get('q',None)
      titles = cache.get('titles')
      if titles==None:
          print ('load data...')
          texts = []
          mobjs = MovieData.objects.all()
          ndim = mobjs[0].ndim
          matr = np.empty([1,ndim])
  
      else:
          print ('loaded',str(len(titles)))
  </code></pre>