示例#1
0
from django.urls import path

from products.views import ProductDetailView, ProductListView, ProductCreateView, ProductUpdateView, ProductDeleteView, \
    ProductDownloadView

app_name = "products"
urlpatterns = [
    path('', ProductListView.as_view(), name="index"),
    path('<int:pk>', ProductDetailView.as_view(), name="detail"),
    path('<slug:slug>', ProductDetailView.as_view(), name="detail_slug"),
    path('<int:id>/download', ProductDownloadView.as_view(), name="download"),
    path('<slug:slug>/download',
         ProductDownloadView.as_view(),
         name="download_slug"),
    path('create/', ProductCreateView.as_view(), name="create"),
    path('<int:pk>/edit', ProductUpdateView.as_view(), name="update"),
    path('<slug:slug>/edit', ProductUpdateView.as_view(), name="update_slug"),
    path('<int:pk>/delete', ProductDeleteView.as_view(), name="delete"),
    path('<slug:slug>/delete', ProductDeleteView.as_view(),
         name="delete_slug"),
]
示例#2
0
from django.urls import path

# Импортируем свою функцию
from products.views import (ProductCreateView, ProductUpdateView,
                            ProductDeleteView, ProductListView,
                            ProductDetailView, product_list, product_detail,
                            product_create, product_update, product_delete)

app_name = 'products'

urlpatterns = [
    path('<int:pk>/delete/', ProductDeleteView.as_view(), name='delete'),
    path('<int:pk>/update/', ProductUpdateView.as_view(), name='update'),
    # path('create/', product_create, name='create'),
    path('create/', ProductCreateView.as_view(), name='create'),
    path('<int:pk>/', ProductDetailView.as_view(), name='detail'),
    path('', ProductListView.as_view(), name='catalog'),
]
示例#3
0
from django.contrib import admin
from django.urls import path
from django.conf.urls.static import static
from django.conf import settings
from products.views import (
    ProductListView,
    ProductDetailView,
    ProductCreateView,
    ProductUpdateView,
    ProductDeleteView,
)
from django.views.generic.base import RedirectView

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', RedirectView.as_view(url='products/'), name='home'),
    path('products/', ProductListView.as_view(), name='product-list'),
    path('products/<int:pk>',
         ProductDetailView.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'),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
示例#4
0
The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.8/topics/http/urls/
Examples:
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. Add an import:  from blog import urls as blog_urls
    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import include, url
from django.contrib import admin
from products.views import ProductUpdateView, ProductDeleteView

urlpatterns = [

    url(r'^$', 'products.views.home', name='home'),

    # Products urls
    url(r'^products/$', 'products.views.products_list', name='products'),
    url(r'^products/add$', 'products.views.products_add', name='products_add'),
    url(r'^products/(?P<pk>\d+)/edit/$', ProductUpdateView.as_view(), name='products_edit'),
    url(r'^products/(?P<pk>\d+)/delete/$', ProductDeleteView.as_view(), name='products_delete'),

    url(r'^admin/', include(admin.site.urls)),

]
示例#5
0
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.urls import path


from products.views import (
    products,
    product_view,
    product_create_view,
    product_update_view,
    product_delete_view,
    ProductListView,
    ProductDetailView,
    ProductCreateView,
    ProductUpdateView,
    ProductDeleteView

)

app_name = 'products'

urlpatterns = [
    path('', ProductListView.as_view(), name='products'),
    path('create/', ProductCreateView.as_view(), name='create'),
    path('<str:slug>/', ProductDetailView.as_view(), name='view'),
    path('<str:slug>/update/', ProductUpdateView.as_view(), name='update'),
    path('<str:slug>/delete/', ProductDeleteView.as_view(), name='delete'),
]
示例#6
0
from carts.views import CartView, CheckoutView, CheckoutFinalView
from orders.views import AddressSelectFormView, UserAddressCreateView, OrderList, OrderDetail

urlpatterns = [
    url(r"^$", TemplateView.as_view(template_name = "index.html"), name="index"),
    url(r'^admin/', admin.site.urls),
    url(r'^accounts/', include('allauth.urls')),

    url(r'^products/$',
        ProductListView.as_view(), name = "products_list_view"),
    url(r'^create/product$',
        ProductCreateView.as_view(), name = "products_create_view"),
    url(r'^update/product/(?P<pk>\d+)$',
        ProductUpdateView.as_view(), name = "products_update_view"),
    url(r'^delete/product/(?P<pk>\d+)$',
        ProductDeleteView.as_view(), name = "products_delete_view"),
    url(r'^products/(?P<pk>\d+)$',
        ProductDetailView.as_view(), name = "products_detail_view"),
    url(r'^products/(?P<slug>[\w-]+)$',
        ProductDetailView.as_view(), name = "products_slug_view"),

    url(r'^cart/$', CartView.as_view(), name = "cart"),

    url(r'^orders/$', OrderList.as_view(), name = "orders"),
    url(r'^orders/(?P<pk>\d+)$', OrderDetail.as_view(), name = "order_detail"),

    url(r'^checkout/$', CheckoutView.as_view(), name = "checkout"),
    url(r'^checkout/address/$',
        AddressSelectFormView.as_view(), name = "address_form"),
    url(r'^checkout/address/add$',
        UserAddressCreateView.as_view(), name = "user_address_create"),
示例#7
0
from django.contrib import admin
from django.urls import path

from products.views import (
    ProductCreateView,
    ProductDetailView,
    ProductDeleteView,
    ProductUpdateView,
    ProductListView

)

app_name = 'products'
urlpatterns = [

    path('product/create/', ProductCreateView.as_view(), name='product-create'),
    path('product/<int:id>/', ProductDetailView.as_view(), name='product-detail'),
    path('product/<int:id>/update/', ProductUpdateView.as_view(), name='product-update'),
    path('product/<int:id>/delete/', ProductDeleteView.as_view(), name='product-delete'),
    path('', ProductListView.as_view(), name='product-list')

]