Django compress error: Invalid input of type: 'CacheKey'

  • A+
Category:Languages

We suddenly started getting this issue when compressing django static files on production servers. Ubuntu 16.04, Python 3.x, Django 1.11. I am using an ansible-playbook to deploy.

The error is as follows:

CommandError: An error occurred during rendering /chalktalk/app/chalktalk-react-40/chalktalk-react-40/chalktalk/apps/exams/templates/exams/section-edit.html: Invalid input of type: 'CacheKey'. Convert to a byte, string or number first.

It doesn't seem to be an issue in one of the static files but a general issue. Every time we run it, we get a different file.

I was looking for any clues on google and nothing shows up with the same error.

 


This appears to be an issue with the underlying redis library. Try pinning your redis version to 2.10.6, from August 17, 2017. The new version 3, released Nov 15, has this incompatible change.

pip install redis==2.10.6 # and/or echo redis==2.10.6 >> requirements.txt 

I am not sure what package you are using which may be requiring redis as a dependency, or if you are using it yourself. In either case its the same process.

I just started having this issue as well, but through the django-redis package, which requires the underlying redis lib. However, that package actually doesn't restrict the maximum version, so it happily upgrades past a major version bump, which you can't really do since thats where you expect the API to change!

The exact code, in master at django-redis:

install_requires = [     "redis>=2.10.0", ] 

But it should really be this

install_requires = [     "redis>=2.10.0, <3", ] 

Edit: I found the bug report in django-redis (#342) about this just now, but this SO question came up first in google when I was looking into it.

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: