multitenant: dont clear the contenttype cache between requests (#47343)
This commit is contained in:
parent
9d11791747
commit
7d0a3162f0
|
@ -12,9 +12,11 @@ from tenant_schemas.utils import get_tenant_model, get_public_schema_name
|
|||
|
||||
SENTINEL = object()
|
||||
|
||||
|
||||
class TenantNotFound(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
class TenantMiddleware(MiddlewareMixin):
|
||||
"""
|
||||
This middleware should be placed at the very top of the middleware stack.
|
||||
|
@ -82,7 +84,8 @@ class TenantMiddleware(MiddlewareMixin):
|
|||
# problems. for example, on public, a particular model has id 14, but on the tenants
|
||||
# it has the id 15. if 14 is cached instead of 15, the permissions for the wrong
|
||||
# model will be fetched.
|
||||
ContentType.objects.clear_cache()
|
||||
if getattr(settings, 'CLEAR_CONTENT_TYPE_CACHE', True):
|
||||
ContentType.objects.clear_cache()
|
||||
|
||||
# do we have a public-specific token?
|
||||
if hasattr(settings, 'PUBLIC_SCHEMA_URLCONF') and request.tenant.schema_name == get_public_schema_name():
|
||||
|
|
Loading…
Reference in New Issue