示例#1
0
from p_library import views
from p_library.views import AuthorEdit, AuthorList, author_create_many, books_authors_create_many, PublisherDetailView
from p_library.views import PublisherList
from p_library.views import index, RegisterView, CreateUserProfile
from allauth.account.views import login, logout
from django.conf.urls.static import static
from django.conf import settings

app_name = 'p_library'

urlpatterns = [
    path('index/book_increment/', views.book_increment),
    path('index/book_decrement/', views.book_decrement),
    path('publisher/', views.book_publisher),
    path('publishers', PublisherList.as_view()),
    path('author/create', AuthorEdit.as_view(), name='author_create'),
    path('authors', AuthorList.as_view(), name='author_list'),
    path('author/create_many', author_create_many, name='author_create_many'),
    path('author_book/create_many',
         books_authors_create_many,
         name='author_book_create_many'),
    path('<int:pk>/', PublisherDetailView.as_view(), name="publisher-detail"),
    path('hometask/', views.hometask, name="hometask-detail"),
    path('', index, name='index'),
    path('register/',
         RegisterView.as_view(
             template_name='register.html',
             success_url=reverse_lazy('p_library:profile-create')),
         name='register'),
    path('profile-create/', CreateUserProfile.as_view(),
         name='profile-create'),
示例#2
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 django.conf.urls.static import static
from django.conf import settings
from p_library import views
from p_library.views import AuthorEdit, AuthorList, BookEdit, BookList, FriendEdit, FriendList, PublisherList

app_name = 'p_library'
urlpatterns = [
    path('admin/', admin.site.urls),
    path('', views.home, name='home'),
    path('index/', views.home, name='home'),
    path('book/', BookList.as_view(), name='book_list'),
    path('book/add', BookEdit.as_view(), name='book_add'),
    path('index/book_increment/', views.book_increment),
    path('index/book_decrement/', views.book_decrement),
    path('author/add/', AuthorEdit.as_view(), name='author_add'),
    path('author/', AuthorList.as_view(), name='author_list'),
    path('friend/add/', FriendEdit.as_view(), name='friend_add'),
    path('friend/', FriendList.as_view(), name='friend_list'),
    path('publisher/', PublisherList.as_view(), name='publisher_list'),
]

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)