From 550f3ce59c2ba594b06e942243815bee79885289 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Sat, 1 Apr 2017 16:12:50 -0400 Subject: [PATCH] Rearrange the urls --- stagestatus/apps/machines/urls.py | 2 +- stagestatus/urls.py | 6 +++--- stagestatus/views.py | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 stagestatus/views.py diff --git a/stagestatus/apps/machines/urls.py b/stagestatus/apps/machines/urls.py index 68e7fd4..c5b0e85 100644 --- a/stagestatus/apps/machines/urls.py +++ b/stagestatus/apps/machines/urls.py @@ -5,5 +5,5 @@ from machines.routers import router urlpatterns = [ url(r'^api/', include(router.urls)), url(r'^(?P\w+)/$', MachineDetail.as_view(), name='machine-detail'), - url(r'^$', MachineList.as_view()), + url(r'^$', MachineList.as_view(), name='machines-list'), ] diff --git a/stagestatus/urls.py b/stagestatus/urls.py index e629dcd..30ff39f 100644 --- a/stagestatus/urls.py +++ b/stagestatus/urls.py @@ -1,9 +1,9 @@ from django.conf.urls import url, include from django.contrib import admin -from django.views.generic import TemplateView +from stagestatus.views import redirect_machines urlpatterns = [ url(r'^admin/', admin.site.urls), - url(r'^machines/', include('machines.urls')), - url(r'^', TemplateView.as_view(template_name='index.html')), + url(r'machines/', include('machines.urls')), + url(r'', redirect_machines), ] diff --git a/stagestatus/views.py b/stagestatus/views.py new file mode 100644 index 0000000..318064f --- /dev/null +++ b/stagestatus/views.py @@ -0,0 +1,6 @@ +from django.http import HttpResponseRedirect +from django.shortcuts import reverse + + +def redirect_machines(request): + return HttpResponseRedirect(reverse('machines-list'))