示例#1
0
    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.conf import settings
from django.contrib import admin
from django.conf.urls.static import static
from django.urls import path, include

from webapp.views import ReviewCreateView, ReviewUpdateView, ReviewDeleteView
from webapp.views.product_views import IndexView, ProductView, ProductCreateView, ProductUpdateView, ProductDeleteView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', IndexView.as_view(), name='index'),
    path('product/<int:pk>/', ProductView.as_view(), name='product_view'),
    path('product/add/', ProductCreateView.as_view(), name='product_create'),
    path('product/<int:pk>/update/', ProductUpdateView.as_view(), name='product_update'),
    path('product/<int:pk>/delete/', ProductDeleteView.as_view(), name='product_delete'),

    path('product/<int:pk>/reviews/add/', ReviewCreateView.as_view(), name='review_create'),
    path('reviews/<int:pk>/update/', ReviewUpdateView.as_view(), name='review_update'),
    path('reviews/<int:pk>/delete/', ReviewDeleteView.as_view(), name='review_delete'),
    path('accounts/', include('accounts.urls'))
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
示例#2
0
from django.urls import path

from webapp.views import IndexView, ProductView, ProductCreateView,ProductUpdateView, ProductDeleteView, ReviewCreateView, ReviewUpdateView, ReviewDeleteView

app_name = 'webapp'

urlpatterns = [
    path('', IndexView.as_view(), name='index'),
    path('products/<int:pk>/', ProductView.as_view(), name='product_detail'),
    path('products/create/', ProductCreateView.as_view(), name='product_create'),
    path('products/<int:pk>/update/', ProductUpdateView.as_view(), name='product_update'),
    path('products/<int:pk>/delete/', ProductDeleteView.as_view(), name='product_delete'),
    path('product/<int:pk>/add-review/', ReviewCreateView.as_view(), name='add_review'),
    path('review/<int:pk>/edit/', ReviewUpdateView.as_view(), name='review_update'),
    path('review/<int:pk>/delete', ReviewDeleteView.as_view(), name='review_delete')
]
示例#3
0
from webapp.views import (
    ProductView,
    ProductDetailView,
    ProductCreate,
    ProductUpdate,
    ProductDelete,
    ReviewCreateView,
    ReviewUpdateView,
    ReviewDelete,
)

urlpatterns = [
    path('', ProductView.as_view(), name='index_all'),
    path('product/<int:id>/', ProductDetailView.as_view(), name='product'),
    path('product/create/', ProductCreate.as_view(), name='product_create'),
    path('product/<int:id>/update',
         ProductUpdate.as_view(),
         name='product_update'),
    path('product/<int:id>/delete',
         ProductDelete.as_view(),
         name='product_delete'),
    path('product/<int:id>/review/add/',
         ReviewCreateView.as_view(),
         name='review_add'),
    path('review/<int:id>/update/',
         ReviewUpdateView.as_view(),
         name='review_update'),
    path('review/<int:id>/delete/',
         ReviewDelete.as_view(),
         name='review_delete'),
]
示例#4
0
from django.urls import path

from webapp.views import ProductListView, ProductDetailView, ProductCreateView, ProductUpdateView, ProductDeleteView, \
    ReviewListView, ReviewCreateView, ReviewUpdateView, ReviewDeleteView

app_name = 'webapp'

urlpatterns = [
    path('', ProductListView.as_view(), name='index'),
    path('product/<int:pk>/', ProductDetailView.as_view(), name='product_detail'),
    path('product/create/', ProductCreateView.as_view(), name='product_create'),
    path('product/<int:pk>/update/', ProductUpdateView.as_view(), name='product_update'),
    path('product/<int:pk>/delete/', ProductDeleteView.as_view(), name='product_delete'),
    path('review/', ReviewListView.as_view(), name='reviews'),
    path('review/add/product/<int:pk>/', ReviewCreateView.as_view(), name="review_add"),
    path('review/update/product/<int:pk>/', ReviewUpdateView.as_view(), name='review_update'),
    path('review/<int:pk>/delete/', ReviewDeleteView.as_view(), name='review_delete')

]