From a0d20a5d50b00e8755ba9844d5f5b469cac801ef Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Wed, 4 Dec 2019 08:38:22 -0500 Subject: [PATCH] fix an nuanced bug which can cause OAuth2 migrations to fail --- awx/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/awx/__init__.py b/awx/__init__.py index b97a5694af..433892edbf 100644 --- a/awx/__init__.py +++ b/awx/__init__.py @@ -86,7 +86,14 @@ def oauth2_getattribute(self, attr): # Custom method to override # oauth2_provider.settings.OAuth2ProviderSettings.__getattribute__ from django.conf import settings - val = settings.OAUTH2_PROVIDER.get(attr) + val = None + if 'migrate' not in sys.argv: + # certain Django OAuth Toolkit migrations actually reference + # setting lookups for references to model classes (e.g., + # oauth2_settings.REFRESH_TOKEN_MODEL) + # If we're doing an OAuth2 setting lookup *while running* a migration, + # don't do our usual "Configure Tower in Tower" database setting lookup + val = settings.OAUTH2_PROVIDER.get(attr) if val is None: val = object.__getattribute__(self, attr) return val