django2: Fix 3-tuple ImproperlyConfigured error
https://docs.djangoproject.com/en/2.0/releases/1.9/#passing-a-3-tuple-or-an-app-name-to-include blueprint django2-support Change-Id: Ifb9b7501363fe8a3ef417498e0932323240a6dcd
This commit is contained in:
parent
1a252cb5e8
commit
18684e1ff5
@ -89,6 +89,24 @@ def access_cached(func):
|
|||||||
return inner
|
return inner
|
||||||
|
|
||||||
|
|
||||||
|
def _wrapped_include(arg):
|
||||||
|
"""Convert the old 3-tuple arg for include() into the new format.
|
||||||
|
|
||||||
|
The argument "arg" should be a tuple with 3 elements:
|
||||||
|
(pattern_list, app_namespace, instance_namespace)
|
||||||
|
|
||||||
|
Prior to Django 2.0, django.urls.conf.include() accepts 3-tuple arg
|
||||||
|
(urlconf, namespace, app_name), but it was droppped in Django 2.0.
|
||||||
|
This function is used to convert the older 3-tuple used in horizon code
|
||||||
|
into the new format where namespace needs to be passed as the second arg.
|
||||||
|
|
||||||
|
For more details, see
|
||||||
|
https://docs.djangoproject.com/en/2.0/releases/1.9/#passing-a-3-tuple-or-an-app-name-to-include
|
||||||
|
"""
|
||||||
|
pattern_list, app_namespace, instance_namespace = arg
|
||||||
|
return include((pattern_list, app_namespace), namespace=instance_namespace)
|
||||||
|
|
||||||
|
|
||||||
class NotRegistered(Exception):
|
class NotRegistered(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -544,12 +562,13 @@ class Dashboard(Registry, HorizonComponent):
|
|||||||
continue
|
continue
|
||||||
url_slug = panel.slug.replace('.', '/')
|
url_slug = panel.slug.replace('.', '/')
|
||||||
urlpatterns.append(url(r'^%s/' % url_slug,
|
urlpatterns.append(url(r'^%s/' % url_slug,
|
||||||
include(panel._decorated_urls)))
|
_wrapped_include(panel._decorated_urls)))
|
||||||
# Now the default view, which should come last
|
# Now the default view, which should come last
|
||||||
if not default_panel:
|
if not default_panel:
|
||||||
raise NotRegistered('The default panel "%s" is not registered.'
|
raise NotRegistered('The default panel "%s" is not registered.'
|
||||||
% self.default_panel)
|
% self.default_panel)
|
||||||
urlpatterns.append(url(r'', include(default_panel._decorated_urls)))
|
urlpatterns.append(
|
||||||
|
url(r'', _wrapped_include(default_panel._decorated_urls)))
|
||||||
|
|
||||||
# Require login if not public.
|
# Require login if not public.
|
||||||
if not self.public:
|
if not self.public:
|
||||||
@ -867,7 +886,7 @@ class Site(Registry, HorizonComponent):
|
|||||||
# Compile the dynamic urlconf.
|
# Compile the dynamic urlconf.
|
||||||
for dash in self._registry.values():
|
for dash in self._registry.values():
|
||||||
urlpatterns.append(url(r'^%s/' % dash.slug,
|
urlpatterns.append(url(r'^%s/' % dash.slug,
|
||||||
include(dash._decorated_urls)))
|
_wrapped_include(dash._decorated_urls)))
|
||||||
|
|
||||||
# add URL for ngdetails
|
# add URL for ngdetails
|
||||||
views = import_module('horizon.browsers.views')
|
views = import_module('horizon.browsers.views')
|
||||||
|
@ -32,7 +32,7 @@ urlpatterns = [
|
|||||||
# Client-side i18n URLconf.
|
# Client-side i18n URLconf.
|
||||||
urlpatterns.extend([
|
urlpatterns.extend([
|
||||||
url(r'^i18n/js/(?P<packages>\S+?)/$',
|
url(r'^i18n/js/(?P<packages>\S+?)/$',
|
||||||
i18n.javascript_catalog,
|
i18n.JavaScriptCatalog.as_view(),
|
||||||
name='jsi18n'),
|
name='jsi18n'),
|
||||||
url(r'^i18n/setlang/$',
|
url(r'^i18n/setlang/$',
|
||||||
i18n.set_language,
|
i18n.set_language,
|
||||||
|
@ -27,11 +27,12 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
|||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
|
import horizon.base
|
||||||
from horizon.test.jasmine import jasmine
|
from horizon.test.jasmine import jasmine
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'', include(horizon.urls)),
|
url(r'', horizon.base._wrapped_include(horizon.urls)),
|
||||||
url(r"auth/login/", views.login, {'template_name': "auth/login.html"},
|
url(r"auth/login/", views.login, {'template_name': "auth/login.html"},
|
||||||
name='login'),
|
name='login'),
|
||||||
url(r'auth/', include('django.contrib.auth.urls')),
|
url(r'auth/', include('django.contrib.auth.urls')),
|
||||||
|
@ -25,5 +25,5 @@ urlpatterns = [
|
|||||||
views.AdminDetailView.as_view(),
|
views.AdminDetailView.as_view(),
|
||||||
name='detail'),
|
name='detail'),
|
||||||
url(r'^$', views.AdminIndexView.as_view(), name='index'),
|
url(r'^$', views.AdminIndexView.as_view(), name='index'),
|
||||||
url(r'', include(compute_urls, namespace='compute')),
|
url(r'', include((compute_urls, 'compute'))),
|
||||||
]
|
]
|
||||||
|
@ -53,6 +53,6 @@ urlpatterns = [
|
|||||||
url(r'^(?P<network_id>[^/]+)/ports/(?P<port_id>[^/]+)/update$',
|
url(r'^(?P<network_id>[^/]+)/ports/(?P<port_id>[^/]+)/update$',
|
||||||
port_views.UpdateView.as_view(), name='editport'),
|
port_views.UpdateView.as_view(), name='editport'),
|
||||||
|
|
||||||
url(r'^subnets/', include(subnet_urls, namespace='subnets')),
|
url(r'^subnets/', include((subnet_urls, 'subnets'))),
|
||||||
url(r'^ports/', include(port_urls, namespace='ports')),
|
url(r'^ports/', include((port_urls, 'ports'))),
|
||||||
]
|
]
|
||||||
|
@ -37,7 +37,7 @@ urlpatterns = [
|
|||||||
views.EditQosSpecConsumerView.as_view(),
|
views.EditQosSpecConsumerView.as_view(),
|
||||||
name='edit_qos_spec_consumer'),
|
name='edit_qos_spec_consumer'),
|
||||||
url(r'^(?P<type_id>[^/]+)/extras/',
|
url(r'^(?P<type_id>[^/]+)/extras/',
|
||||||
include(extras_urls, namespace='extras')),
|
include((extras_urls, 'extras'))),
|
||||||
url(r'^(?P<volume_type_id>[^/]+)/create_type_encryption/$',
|
url(r'^(?P<volume_type_id>[^/]+)/create_type_encryption/$',
|
||||||
views.CreateVolumeTypeEncryptionView.as_view(),
|
views.CreateVolumeTypeEncryptionView.as_view(),
|
||||||
name='create_type_encryption'),
|
name='create_type_encryption'),
|
||||||
@ -48,7 +48,7 @@ urlpatterns = [
|
|||||||
views.VolumeTypeEncryptionDetailView.as_view(),
|
views.VolumeTypeEncryptionDetailView.as_view(),
|
||||||
name='type_encryption_detail'),
|
name='type_encryption_detail'),
|
||||||
url(r'^qos_specs/',
|
url(r'^qos_specs/',
|
||||||
include(qos_specs_urls, namespace='qos_specs')),
|
include((qos_specs_urls, 'qos_specs'))),
|
||||||
url(r'^(?P<volume_type_id>[^/]+)/edit_access/$',
|
url(r'^(?P<volume_type_id>[^/]+)/edit_access/$',
|
||||||
views.EditAccessView.as_view(), name='edit_access'),
|
views.EditAccessView.as_view(), name='edit_access'),
|
||||||
]
|
]
|
||||||
|
@ -32,5 +32,5 @@ urlpatterns = [
|
|||||||
views.UpdateView.as_view(), name='update'),
|
views.UpdateView.as_view(), name='update'),
|
||||||
url(r'^register/$', views.RegisterView.as_view(), name='register'),
|
url(r'^register/$', views.RegisterView.as_view(), name='register'),
|
||||||
url(r'(?P<identity_provider_id>[^/]+)/protocols/',
|
url(r'(?P<identity_provider_id>[^/]+)/protocols/',
|
||||||
include(protocol_urls, namespace='protocols')),
|
include((protocol_urls, 'protocols'))),
|
||||||
]
|
]
|
||||||
|
@ -34,12 +34,12 @@ if settings.ANGULAR_FEATURES['images_panel']:
|
|||||||
# New angular images
|
# New angular images
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', AngularIndexView.as_view(title=title), name='index'),
|
url(r'^$', AngularIndexView.as_view(title=title), name='index'),
|
||||||
url(r'', include(image_urls, namespace='images')),
|
url(r'', include((image_urls, 'images'))),
|
||||||
url(r'', include(snapshot_urls, namespace='snapshots')),
|
url(r'', include((snapshot_urls, 'snapshots'))),
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||||
url(r'', include(image_urls, namespace='images')),
|
url(r'', include((image_urls, 'images'))),
|
||||||
url(r'', include(snapshot_urls, namespace='snapshots')),
|
url(r'', include((snapshot_urls, 'snapshots'))),
|
||||||
]
|
]
|
||||||
|
@ -48,6 +48,6 @@ urlpatterns = [
|
|||||||
subnet_views.UpdateView.as_view(), name='editsubnet'),
|
subnet_views.UpdateView.as_view(), name='editsubnet'),
|
||||||
url(r'^(?P<network_id>[^/]+)/ports/(?P<port_id>[^/]+)/update$',
|
url(r'^(?P<network_id>[^/]+)/ports/(?P<port_id>[^/]+)/update$',
|
||||||
port_views.UpdateView.as_view(), name='editport'),
|
port_views.UpdateView.as_view(), name='editport'),
|
||||||
url(r'^subnets/', include(subnet_urls, namespace='subnets')),
|
url(r'^subnets/', include((subnet_urls, 'subnets'))),
|
||||||
url(r'^ports/', include(port_urls, namespace='ports')),
|
url(r'^ports/', include((port_urls, 'ports'))),
|
||||||
]
|
]
|
||||||
|
@ -24,6 +24,8 @@ from django.conf.urls import url
|
|||||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
from django.views import defaults
|
from django.views import defaults
|
||||||
|
|
||||||
|
import horizon.base
|
||||||
|
|
||||||
from openstack_dashboard.api import rest
|
from openstack_dashboard.api import rest
|
||||||
from openstack_dashboard.test.jasmine import jasmine
|
from openstack_dashboard.test.jasmine import jasmine
|
||||||
from openstack_dashboard import views
|
from openstack_dashboard import views
|
||||||
@ -35,7 +37,7 @@ urlpatterns = [
|
|||||||
url(r'^auth/', include('openstack_auth.urls')),
|
url(r'^auth/', include('openstack_auth.urls')),
|
||||||
url(r'^api/', include(rest.urls)),
|
url(r'^api/', include(rest.urls)),
|
||||||
url(r'^jasmine/(.*?)$', jasmine.dispatcher),
|
url(r'^jasmine/(.*?)$', jasmine.dispatcher),
|
||||||
url(r'', include(horizon.urls)),
|
url(r'', horizon.base._wrapped_include(horizon.urls)),
|
||||||
]
|
]
|
||||||
|
|
||||||
# Development static app and project media serving using the staticfiles app.
|
# Development static app and project media serving using the staticfiles app.
|
||||||
|
@ -28,6 +28,7 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
|||||||
from django.views import defaults
|
from django.views import defaults
|
||||||
|
|
||||||
import horizon
|
import horizon
|
||||||
|
import horizon.base
|
||||||
|
|
||||||
from openstack_dashboard.api import rest
|
from openstack_dashboard.api import rest
|
||||||
from openstack_dashboard import views
|
from openstack_dashboard import views
|
||||||
@ -36,7 +37,7 @@ urlpatterns = [
|
|||||||
url(r'^$', views.splash, name='splash'),
|
url(r'^$', views.splash, name='splash'),
|
||||||
url(r'^api/', include(rest.urls)),
|
url(r'^api/', include(rest.urls)),
|
||||||
url(r'^header/', views.ExtensibleHeaderView.as_view()),
|
url(r'^header/', views.ExtensibleHeaderView.as_view()),
|
||||||
url(r'', include(horizon.urls)),
|
url(r'', horizon.base._wrapped_include(horizon.urls)),
|
||||||
]
|
]
|
||||||
|
|
||||||
for u in getattr(settings, 'AUTHENTICATION_URLS', ['openstack_auth.urls']):
|
for u in getattr(settings, 'AUTHENTICATION_URLS', ['openstack_auth.urls']):
|
||||||
|
Loading…
Reference in New Issue
Block a user