Update urls logic to django 2
This commit is contained in:
parent
7087ca6ae8
commit
c7a28e8f7c
@ -1,6 +1,8 @@
|
|||||||
from django.conf.urls import url, include
|
from django.conf.urls import include
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.urls import path
|
||||||
from rest_framework import routers
|
from rest_framework import routers
|
||||||
|
|
||||||
from billard import views
|
from billard import views
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
router = routers.DefaultRouter()
|
||||||
@ -9,20 +11,19 @@ router.register(r'locationdata', views.LocationDataViewSet)
|
|||||||
app_name = 'billard'
|
app_name = 'billard'
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# ex. /billard/
|
# ex. /billard/
|
||||||
url(r'^$', login_required(views.LocationIndexView.as_view()), name='location_index'),
|
path('', login_required(views.LocationIndexView.as_view()), name='location_index'),
|
||||||
# ex. /billard/1/
|
# ex. /billard/1/
|
||||||
url(r'^(?P<pk>[0-9]+)/$', login_required(views.LocationDetailView.as_view()), name='location_detail'),
|
path('<int:pk>/', login_required(views.LocationDetailView.as_view()), name='location_detail'),
|
||||||
# ex. /billard/1/accounting/
|
# ex. /billard/1/accounting/
|
||||||
url(r'^(?P<pk>[0-9]+)/accounting/$', views.AccountingView.as_view(), name='accounting_detail'),
|
path('<int:pk>/accounting/', views.AccountingView.as_view(), name='accounting_detail'),
|
||||||
# ex. /billard/1/accounting/confirm
|
# ex. /billard/1/accounting/confirm
|
||||||
url(r'^(?P<pk>[0-9]+)/accounting/confirm/$', views.accounting_confirm, name='accounting_detail_confirm'),
|
path('<int:pk>/accounting/confirm/', views.accounting_confirm, name='accounting_detail_confirm'),
|
||||||
# ex. /billard/1/account_modal/
|
# ex. /billard/1/account_modal/
|
||||||
url(r'^(?P<loc_pk>[0-9]+)/account_modal/$', views.account_modal_view, name='account_modal'),
|
path('<int:loc_pk>/account_modal/', views.account_modal_view, name='account_modal'),
|
||||||
# ex. /billard/1/account_modal/confirm/
|
# ex. /billard/1/account_modal/confirm/
|
||||||
url(r'^(?P<loc_pk>[0-9]+)/account_modal/(?P<pks>[0-9]+(,[0-9]+)*)/confirm/$', views.account_modal_confirm_view,
|
path('<int:loc_pk>/account_modal/<pks>/confirm/', views.account_modal_confirm_view, name='account_modal_confirm'),
|
||||||
name='account_modal_confirm'),
|
|
||||||
# ex. /billard/api/v1/ (rest api)
|
# ex. /billard/api/v1/ (rest api)
|
||||||
url(r'api/v1/', include(router.urls)),
|
path('api/v1/', include(router.urls)),
|
||||||
# ex. /billard/process_location_data/
|
# ex. /billard/process_location_data/
|
||||||
url(r'^process_location_data/$', views.process_location_data, name='process_location_data'),
|
path('process_location_data/', views.process_location_data, name='process_location_data'),
|
||||||
]
|
]
|
||||||
|
@ -14,23 +14,25 @@ Including another URLconf
|
|||||||
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
||||||
"""
|
"""
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import url, include
|
from django.conf.urls import include
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.contrib.auth import views as auth_views
|
from django.contrib.auth import views as auth_views
|
||||||
|
from django.urls import path
|
||||||
from django.views.generic import RedirectView
|
from django.views.generic import RedirectView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
||||||
url(r'^billard/', include('billard.urls')),
|
path('billard/', include('billard.urls')),
|
||||||
url(r'^login/$', auth_views.login, name='login'),
|
path('login/', auth_views.login, name='login'),
|
||||||
url(r'^logout/$', auth_views.logout, name='logout'),
|
path('logout/', auth_views.logout, name='logout'),
|
||||||
url(r'^', include('django.contrib.auth.urls')),
|
path('', include('django.contrib.auth.urls')),
|
||||||
url(r'^$', RedirectView.as_view(url='billard/', permanent=False), name='index')
|
path('', RedirectView.as_view(url='billard/', permanent=False), name='index')
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
import debug_toolbar
|
import debug_toolbar
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^__debug__/', include(debug_toolbar.urls)),
|
path('__debug__/', include(debug_toolbar.urls)),
|
||||||
] + urlpatterns
|
] + urlpatterns
|
||||||
|
Loading…
Reference in New Issue
Block a user