The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path

from movielist.views import MovieListView, MovieView
from showtimes.views import CinemaView, CinemaListView, ScreeningListView, ScreeningView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('movies/', MovieListView.as_view(), name='movies'),
    path('movies/<int:pk>/', MovieView.as_view(), name='movies-detail'),
    path('cinemas/', CinemaListView.as_view(), name='cinemas'),
    path('cinemas/<int:pk>/', CinemaView.as_view(), name='cinemas-detail'),
    path('screenings/', ScreeningListView.as_view(), name='screenings'),
    path('screenings/<int:pk>/',
         ScreeningView.as_view(),
         name='screenings-detail'),
]
示例#2
0
文件: urls.py 项目: janstawowy/rest
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.urls import path, re_path
from django.contrib import admin
from movielist.views import MovieListView, MovieView
from showtimes.views import CinemaListView, CinemaView, ScreeningListView, ScreeningView, FilteredScreeningListView, FilteredCinemaListView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^movies/$', MovieListView.as_view()),
    url(r'^movies/(?P<pk>[0-9]+)', MovieView.as_view(), name='moviedetail'),
    url(r'^cinemas/$', CinemaListView.as_view()),
    url(r'^cinemas/(?P<pk>[0-9]+)', CinemaView.as_view(), name='cinemadetail'),
    url(r'^screening/$', ScreeningListView.as_view()),
    url(r'^screening/(?P<pk>[0-9]+)',
        ScreeningView.as_view(),
        name='screeningdetail'),
    url(r'^screening/(?P<title>[a-zA-Z ]+)',
        FilteredScreeningListView.as_view()),
    url(r'^cinemas/(?P<city>[a-zA-Z ]+)', FilteredCinemaListView.as_view()),
]
示例#3
0
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path

from movielist.views import MovieListView, MovieView
from showtimes.views import CinemaListView, CinemaView, ScreeningListView, ScreeningView

# API endpoints
urlpatterns = [
    path('admin/', admin.site.urls),
    path('movies/', MovieListView.as_view()),
    path('movies/<int:pk>/', MovieView.as_view(), name="movie-details"),
    path('cinemas/', CinemaListView.as_view(), name='cinemas-list'),
    path('cinemas/<int:pk>/', CinemaView.as_view(), name='cinema-view'),
    path('screenings/',
         ScreeningListView.as_view({
             'get': 'list',
             'post': 'create',
             'put': 'update'
         }),
         name='screenings-list'),
    path('screenings/<int:pk>/',
         ScreeningView.as_view(),
         name='screening-view'),
]
示例#4
0
from django.conf.urls import url
from django.contrib import admin

from movielist.views import MovieListView, MovieView
from showtimes.views import CinemaListView, CinemaView, ScreeningsListView, ScreeningView

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^movies/$', MovieListView.as_view()),
    url(r'^movies/(?P<pk>[0-9]+)/$', MovieView.as_view()),
    url(r'^cinemas/$', CinemaListView.as_view()),
    url(r'^cinemas/(?P<pk>[0-9]+)/$', CinemaView.as_view()),
    url(r'^screens/$', ScreeningsListView.as_view()),
    url(r'^screens/(?P<pk>[0-9]+)/$', ScreeningView.as_view()),
]
    # Main views
    re_path(r'^admin/', admin.site.urls),
    re_path(r"^$", api_root),
    re_path(r"schema/?$", schema_view),

    # User views
    re_path(r'^users/?$', UserListView.as_view(), name="users"),
    re_path(r'^users/(?P<pk>[0-9]+)/?$',
            UserDetailView.as_view(),
            name="user-detail"),
    re_path(r"^current_user/?$", current_user),

    # Movies
    re_path(r'^movies/?$', MovieListView.as_view(), name="movies"),
    re_path(r'^movies/(?P<pk>[0-9]+)/?$',
            MovieView.as_view(),
            name="movie-detail"),

    # Cinemas
    re_path(r'^cinemas/?$', CinemaListView.as_view(), name="cinemas"),
    re_path(r'^cinemas/(?P<pk>[0-9]+)/?$',
            CinemaView.as_view(),
            name="cinema-detail"),

    # Screenings
    re_path(r'^screenings/?$', ScreeningsListView.as_view(),
            name="screenings"),
    re_path(r'^screenings/(?P<pk>[0-9]+)/?$',
            ScreeningView.as_view(),
            name="screening-detail"),
]