title: Troubleshooting 'itertools.chain' object has no attribute '__getitem__'
body: <p>I'm using <code>itertools.chain</code> method in Python to chain several Django <code>Querysets</code> together. By doing so, I'm not touching the database and this is the efficient behaviour I need. However, I'm using a third-party library to paginate these results and this library only accepts list and queryset objects. When calling it with the chain object I get the following error:</p>
  
  <pre><code>Exception Value: 'itertools.chain' object has no attribute '__getitem__'
  </code></pre>
  
  <p>The line in the library (<a href="https://github.com/pennersr/django-pagemore/blob/master/pagemore/templatetags/pagemore.py#L106" rel="nofollow noreferrer">django-pagemore</a>) that is actually diving me crazy is:</p>
  
  <pre><code>objects = self.objects[page0*self.per_page:1+page*self.per_page]
  </code></pre>
  
  <p><strong>The problem here is that when using a chain you can't slice it.</strong></p>
  
  <p>I know that I could convert the chain object into a list easily with <code>list()</code> method, but this would evaluate the ENTIRE queryset and this can contain thousands of items inside.</p>
  
  <p>After some research on <a href="https://stackoverflow.com/a/565382/955619">how to calculate the size of a Python object</a> 
  I did some testing and using <code>sys.getsizeof(cPickle.dumps(content))</code> (where <code>content</code> is one of the objects inside the chain) gives me a value of <code>15,915 bytes</code>, so a chain containing 3,000 of these objects would need <code>45.53 MB</code> aprox!</p>