Commit 5590fcb2 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Rework URLconf application namespacing for API sub-apps

The previous method is removed in Django 2.0 and is causing
all kinds of warnings in testing with pytest.
parent f28869fa
from django.conf.urls import url, include
from .v1 import urls as v1_urls
from .v2 import urls as v2_urls
app_name = 'api'
urlpatterns = [
url(r'^', include('api.v1.urls', namespace='default')),
url(r'^v1/', include('api.v1.urls', namespace='v1')),
url(r'^v2/', include('api.v2.urls', namespace='v2')),
url(r'^', include((v1_urls, 'default'))),
url(r'^v1/', include((v1_urls, 'v1'))),
url(r'^v2/', include((v2_urls, 'v2'))),
......@@ -71,6 +71,7 @@ def is_api_request(request_path):
api_app_name = 'api'
resolver_match = resolve(request_path)
if (resolver_match.app_name == api_app_name):
if (resolver_match.app_names and
resolver_match.app_names[0] == api_app_name):
return True
return False
......@@ -3,6 +3,7 @@ from django.conf.urls import url, include
from .views import *
from .settings import SUPEREVENT_LOOKUP_REGEX
# URL kwarg for superevent detail and nested pages
SUPEREVENT_DETAIL_ROOT = '(?P<{lookup_url_kwarg}>{regex})'.format(
......@@ -5,6 +5,9 @@ from django.conf.urls import url, include
from .main.views import GracedbRoot, PerformanceInfo, TagList, UserInfoView, \
CertDebug, CertInfosDebug
from .events import urls as event_urls
from .superevents import urls as superevent_urls
urlpatterns = [
# Root level API resources ------------------------------------------------
......@@ -26,10 +29,8 @@ urlpatterns = [
# name='cert-infos-debug'),
# Events section of the API -----------------------------------------------
url(r'^events/', include('',
url(r'^events/', include((event_urls, 'events'))),
# Superevents section of the API ------------------------------------------
url(r'^superevents/', include('api.v1.superevents.urls',
url(r'^superevents/', include((superevent_urls, 'superevents'))),
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment