summaryrefslogtreecommitdiff
path: root/django/contrib/auth/migrations/0011_update_proxy_permissions.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/contrib/auth/migrations/0011_update_proxy_permissions.py')
-rw-r--r--django/contrib/auth/migrations/0011_update_proxy_permissions.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/django/contrib/auth/migrations/0011_update_proxy_permissions.py b/django/contrib/auth/migrations/0011_update_proxy_permissions.py
index c3f617f438..7409ea1254 100644
--- a/django/contrib/auth/migrations/0011_update_proxy_permissions.py
+++ b/django/contrib/auth/migrations/0011_update_proxy_permissions.py
@@ -23,6 +23,7 @@ def update_proxy_model_permissions(apps, schema_editor, reverse=False):
style = color_style()
Permission = apps.get_model('auth', 'Permission')
ContentType = apps.get_model('contenttypes', 'ContentType')
+ alias = schema_editor.connection.alias
for Model in apps.get_models():
opts = Model._meta
if not opts.proxy:
@@ -34,13 +35,14 @@ def update_proxy_model_permissions(apps, schema_editor, reverse=False):
permissions_query = Q(codename__in=proxy_default_permissions_codenames)
for codename, name in opts.permissions:
permissions_query = permissions_query | Q(codename=codename, name=name)
- concrete_content_type = ContentType.objects.get_for_model(Model, for_concrete_model=True)
- proxy_content_type = ContentType.objects.get_for_model(Model, for_concrete_model=False)
+ content_type_manager = ContentType.objects.db_manager(alias)
+ concrete_content_type = content_type_manager.get_for_model(Model, for_concrete_model=True)
+ proxy_content_type = content_type_manager.get_for_model(Model, for_concrete_model=False)
old_content_type = proxy_content_type if reverse else concrete_content_type
new_content_type = concrete_content_type if reverse else proxy_content_type
try:
- with transaction.atomic():
- Permission.objects.filter(
+ with transaction.atomic(using=alias):
+ Permission.objects.using(alias).filter(
permissions_query,
content_type=old_content_type,
).update(content_type=new_content_type)