[Django]-Cannot concatenate 'str' and 'tuple' objects โ€“ Django โ€“ johnny cache

1๐Ÿ‘

โœ…

I have had the exact same issue. While I am still trying to get to the exact bottom of it, I have found some useful things.

  1. Older versions of johnny cache work. Since I need master/slave setups to work, I used this fork: https://bitbucket.org/skoczen/johnny-cache It only includes commits up to November, so the problem is introduced after that.

  2. On the admin pages, the error is caused by the auth_user and auth_table table caches. Adding these to the JOHNNY_BLACKLIST circumvents the issue, and also disables caching for those tables. I doubt the issue is unique to those tables, so Iโ€™m blacklisting those tables is not a good solution.

I have checked my configuration and tried many things, just like you and that is not the problem.

Hope this helps.

Edit:
More digging has revealed that the issue crops up with this commit bcdb46c5d357, which added code to cache queries returning null: https://bitbucket.org/jmoiron/johnny-cache/changeset/bcdb46c5d357

If you stick to an earlier one, it should work.

๐Ÿ‘คgkp

0๐Ÿ‘

Then the ordering of middlewares could be the reason of the error, try

'johnny.middleware.LocalStoreClearMiddleware',
'johnny.middleware.QueryCacheMiddleware', # Here
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',    
# Probably you need this for transaction, later
# 'johnny.middleware.CommittingTransactionMiddleware',

The 'johnny.middleware.QueryCacheMiddleware' should be initialized and thus be placed before other middlewares. 'johnny.middleware.LocalStoreClearMiddleware' only deals w/ response and exception, thus it could be the first.

๐Ÿ‘คokm

Leave a comment