postgresql_backend: fix typo in contenttypes cache access and clear base Content.objects._cache (#32248)

This commit is contained in:
Benjamin Dauvergne 2019-04-15 13:48:06 +02:00
parent 68c98a6267
commit c5d54b917e
1 changed files with 4 additions and 1 deletions

View File

@ -193,7 +193,7 @@ class ContentTypeCacheDescriptor(object):
@lru_cache(maxsize=200)
def get_cache(schema_name):
return {}
global_cache[obj.model] = get_cache
model_cache[obj.model] = get_cache
tenant = getattr(connection, 'tenant', None)
schema_name = getattr(tenant, 'schema_name', 'public')
return get_cache(schema_name)
@ -207,6 +207,9 @@ def ContentTypeManager_new__init__(self, *args, **kwargs):
del self._cache
ContentTypeManager.__init__ = ContentTypeManager_new__init__
if '_cache' in ContentType.objects.__dict__:
del ContentType.objects._cache
if hasattr(ContentType._meta, 'local_managers'):
for manager in ContentType._meta.local_managers:
if '_cache' in manager.__dict__: