diff --git a/awx/conf/views.py b/awx/conf/views.py index b18e5c5704..8f4e003654 100644 --- a/awx/conf/views.py +++ b/awx/conf/views.py @@ -6,6 +6,7 @@ import collections import sys # Django +from django.conf import settings from django.core.urlresolvers import reverse from django.http import Http404 from django.utils.translation import ugettext_lazy as _ @@ -118,6 +119,13 @@ class SettingSingletonDetail(RetrieveUpdateDestroyAPIView): for setting in self.get_queryset().exclude(key='LICENSE'): setting.delete() + # When TOWER_URL_BASE is deleted from the API, reset it to the hostname + # used to make the request as a default. + if hasattr(instance, 'TOWER_URL_BASE'): + url = '{}://{}'.format(self.request.scheme, self.request.get_host()) + if settings.TOWER_URL_BASE != url: + settings.TOWER_URL_BASE = url + # Create view functions for all of the class-based views to simplify inclusion # in URL patterns and reverse URL lookups, converting CamelCase names to