Esempio n. 1
0
from django.contrib.auth.views import LoginView, LogoutView
from django.urls import path

from shop.views import SignUpView, ProductDetailView, AddProductToCartView, CartView, HomeView

urlpatterns = [
    path('', HomeView.as_view(), name='home'),
    path('signup/', SignUpView.as_view(), name='signup'),
    path('login/', LoginView.as_view(template_name='shop/login.html'), name='login'),
    path('logout/', LogoutView.as_view(), name='logout'),
    path('catalog/<slug:product>/', ProductDetailView.as_view(), name='product'),
    path('cart/', CartView.as_view(), name='cart'),
    path('cart/add/<int:product_id>/', AddProductToCartView.as_view(), name='add-product')
]
Esempio n. 2
0
from django.urls import path
from django.conf.urls.static import static
from django.conf import settings
from shop.views import ProductListView, ProductDetailView, oreder_success

app_name = 'shop'

urlpatterns = [
    path('', ProductListView.as_view(), name='list'),
    path('<int:pk>', ProductDetailView.as_view(), name='detail'),
    path('success', oreder_success, name='success')
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
 def test_product_detail_get(self):
     response = self.client.get(reverse('shop:product-detail', args=[self.product.pk, self.product.slug]))
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.resolver_match.func.__name__, ProductDetailView.as_view().__name__)
     self.assertTemplateUsed(response, 'shop/product_detail.html')
Esempio n. 4
0
from django.urls import path, include

from shop.views import signup, ProductDetailView, IndexView, order_product, CustomerOrderListView, \
    CustomerOrderDetailView

urlpatterns = [
    path('customers/', include('django.contrib.auth.urls')),
    path('', IndexView.as_view(), name='index'),
    path('signup/', signup, name="signup"),
    path('products/<int:pk>/',
         ProductDetailView.as_view(),
         name='product-detail'),
    path('products/<int:product_id>/order/',
         order_product,
         name='order-product'),
    path('orders/',
         CustomerOrderListView.as_view(),
         name='customer-order-list'),
    path('orders/<int:pk>/',
         CustomerOrderDetailView.as_view(),
         name='customer-order-detail'),
]
Esempio n. 5
0
from django.conf.urls import patterns, include, url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from shop.views import ProductListView, ProductDetailView, MainView, CategoryListView, CategoryDetailView

urlpatterns = patterns('',

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

    url(r'^$', MainView.as_view(), name='index'),

    url(r'^api/product/$', ProductListView.as_view(), name='product-list'),
    url(r'^api/product/(?P<id>[0-9]+)$', ProductDetailView.as_view(), name='product-detail'),

    url(r'^api/category/$', CategoryListView.as_view(), name='category-list'),
    url(r'^api/category/(?P<id>[0-9]+)$', CategoryDetailView.as_view(), name='category-detail'),

    url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
)

urlpatterns += staticfiles_urlpatterns()
Esempio n. 6
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, include, re_path

from shop.views import OrderListingView, ProductListingView, CartView, ProductDetailView, AddToCartView, \
    RemoveFromCartView, \
    OrderDetailView, CustomerListingView, CustomerDetailView, SuccessView

urlpatterns = [
    path('', ProductListingView.as_view()),
    path('cart/', CartView.as_view(), name="cart"),
    re_path(r'^product/(?P<pk>\d+)$', ProductDetailView.as_view(), name='product-detail'),
    re_path(r'^add_to_cart/(?P<pk>\d+)$', AddToCartView.as_view(), name='add-to-cart'),
    re_path(r'^remove_from_cart/(?P<pk>\d+)$', RemoveFromCartView.as_view(), name='remove-from-cart'),
    re_path(r'^order/(?P<pk>\d+)$', OrderDetailView.as_view(), name='order-detail'),
    path('orders/', OrderListingView.as_view()),
    path('customers/', CustomerListingView.as_view()),
    re_path(r'^customer/(?P<pk>\d+)$', CustomerDetailView.as_view(), name='customer-detail'),
    path('cart/success/', SuccessView.as_view()),

    path('admin/', admin.site.urls),
    path('accounts/', include('accounts.urls')),
    path('accounts/', include('django.contrib.auth.urls')),

]
Esempio n. 7
0
from django.conf.urls import url
from shop.views import ProductListView, ProductDetailView

urlpatterns = [
    # url(r'^list-user/$', UserList.as_view(), name='list-user'),
    # url(r'^edit-group/(?P<id>\d+)/$', GroupEdit.as_view(), name='edit-group'),
    # url(r'^create-group/$', GroupCreate.as_view(), name='create-group'),

    url(r'^list-product/$', ProductListView.as_view(), name='product_list'),
    url(r'^list-product/(?P<category_slug>[-\w]+)/$', ProductListView.as_view(), name='product_list_by_category'),
    url(r'^detail-product/(?P<id>\d+)/(?P<slug>[-\w]+)/$', ProductDetailView.as_view(), name='product_detail'),
]