Django: 'BaseTable' object does not support indexing
Question: I'm migrating my project to Django 1.8 and I am receiving an error related to
'johnny cache. Specifically in 'johnny/cache.py/'.

**Error:** lib/python2.7/site-packages/johnny/cache.py", line 87, in
get_tables_for_query tables = set([v[0] for v in getattr(query, 'alias_map',
{}).values()])

**TypeError: 'BaseTable' object does not support indexing**

I have included my code below for the function where the error is originating
from. Advice no whether I should use something other than 'johnny -cache' for
caching would be helpful and/or info as to what is the meaning of this error
and how to fix it. Thank you!

    
    
    def get_tables_for_query(query):
    """
    Takes a Django 'query' object and returns all tables that will be used in
    that query as a list.  Note that where clauses can have their own
    querysets with their own dependent queries, etc.
    """
    from django.db.models.sql.where import WhereNode, SubqueryConstraint
    from django.db.models.query import QuerySet
    tables = set([v[0] for v in getattr(query, 'alias_map', {}).values()])
    
    
    def get_sub_query_tables(node):
        query = node.query_object
        if not hasattr(query, 'field_names'):
            query = query.values(*node.targets)
        else:
            query = query._clone()
        query = query.query
        return set([v[0] for v in getattr(query, 'alias_map',{}).values()])
    
    def get_tables(node, tables):
        if isinstance(node, SubqueryConstraint):
            return get_sub_query_tables(node)
        for child in node.children:
            if isinstance(child, WhereNode):  # and child.children:
                tables = get_tables(child, tables)
            elif not hasattr(child, '__iter__'):
                continue
            else:
                for item in (c for c in child if isinstance(c, QuerySet)):
                    tables += get_tables_for_query(item.query)
        return tables
    
    
    
    if query.where and query.where.children:
        where_nodes = [c for c in query.where.children if isinstance(c, (WhereNode, SubqueryConstraint))]
        for node in where_nodes:
            tables += get_tables(node, tables)
    
    return list(set(tables))
    


Answer: Found your problem when I looked a bit further into your library.

From the [Johnny Cache documentation](https://pythonhosted.org/johnny-cache/):

> It works with Django 1.1 thru 1.4 and python 2.4 thru 2.7.

From your question:

> I'm migrating my project to Django 1.8.

In fact, it looks like the library you're using is woefully out of date and no
longer maintained:

> Latest commit d96ea94 on Nov 10, 2014

