mik3y / django-db-multitenant

A simple multi-tenancy solution for Django apps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MemcachedStringEncodingError when using multitenant_key_func

nav opened this issue · comments

I am getting

Keys must be str()'s, not unicode. Convert your unicode strings using mystring.encode(charset)!
when using cache.helper.multitenant_key_func

using key.encode('ascii', 'ignore') or django.utils.encoding.force_text on the returned key fixes it.

I think it's better to apply the required encoding in your app side because you can control every arguments:
https://github.com/mik3y/django-db-multitenant/blob/master/db_multitenant/cache/helper.py#L27

and it avoids costly or surprising results (if some characters are ignored).