def test_wrong_id_exception_404(self): request = HttpRequest() request.method = 'GET' fake_id = random_id = Product.objects.order_by('?').values_list( 'pk', flat=True).first() Product.objects.filter(pk=random_id).delete() self.assertRaises(Http404, ProductView.as_view(), request, fake_id)
def test_wrong_id_exception_404(self): request = HttpRequest() request.method = 'GET' fake_id = random_id = Product.objects.order_by('?').values_list('pk', flat=True).first() Product.objects.filter(pk=random_id).delete() self.assertRaises(Http404, ProductView.as_view(), request, fake_id)
from django.conf.urls import url, patterns, include from django.contrib import admin from django.contrib.auth.decorators import login_required from django.conf.urls.static import static from django.conf import settings from products.views import IndexView, LoginView, LogoutView, CategoryDetailView, ProductView from products.views import CategoryView, LastProductsView admin.autodiscover() urlpatterns = [ url(r'^$', IndexView.as_view(), name='index'), url(r'^admin/', include(admin.site.urls)), url(r'^products/$', CategoryView.as_view(), name='products'), url(r'^login/$', LoginView.as_view(), name='login'), url(r'^logout/$', LogoutView.as_view(), name='logout'), url(r'^products/(?P<slug>[\w-]+)/$', CategoryDetailView.as_view(), name='category'), url(r'^products/(?P<slug>[\w-]+)/(?P<pslug>[\w-]+)$', ProductView.as_view(), name='product'), url(r'^last/$', login_required(LastProductsView.as_view(),login_url='/login/'), name='last'), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.urls import path from products.views import ProductDetailView, BestItemView, ProductView urlpatterns = [ path('', ProductView.as_view()), path('/best-items', BestItemView.as_view()), path('/<int:product_id>', ProductDetailView.as_view()), ]
from django.conf.urls import patterns, include, url from products.views import ProductList, ProductView, ProductCreate, ProductUpdate, delete_product from django.contrib.auth.decorators import login_required, permission_required urlpatterns = patterns( '', #List view url(r'^$', login_required(ProductList.as_view()), name='product_list'), url('^(?P<pk>\d+)/$', ProductView.as_view(), name='product_details'), url('^create/$', ProductCreate.as_view(), name='product_create'), url(r'^(?P<pk>\d+)/update/$', ProductUpdate.as_view(), name='product_update'), url(r'^(?P<product_id>\d+)/delete$', delete_product, name='product_delete'), )
from django.urls import path from products.views import MenuView, MainProductView, ProductView, CategoryView urlpatterns = [ path('/<int:product_id>', ProductView.as_view()), path('/menu-bar', MenuView.as_view()), path('/main', MainProductView.as_view()), path('/category', CategoryView.as_view()), ]
from substitutes.views import SubstituteView from django.contrib import admin from django.urls import path, re_path from django.conf import settings from django.conf.urls.static import static from core.views import index, legal_notice, autocomplete from users.views import (RegisterView, ProfileView, CustomLoginView, CustomLogoutView) urlpatterns = [ path('admin/', admin.site.urls), path('', index, name='index'), path('legal_notice/', legal_notice, name="legal_notice"), path('login/', CustomLoginView.as_view(template_name='users/login.html'), name='login'), path('logout/', CustomLogoutView.as_view(), name='logout'), path('register/', RegisterView.as_view(), name='register'), path('profile/', ProfileView.as_view(), name='profile'), re_path('^substitute/$', SubstituteView.as_view(), name='substitute'), path(r'product/<int:barcode>/', ProductView.as_view(), name='product'), path('favourites/', FavouriteView.as_view(), name='favourite'), path('autocomplete', autocomplete, name='autocomplete') ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.urls import path from products.views import ProductListView, ProductFeaturedView, ProductView urlpatterns = [ path('', ProductListView.as_view()), path('<sku>', ProductView.as_view()), path('featured', ProductFeaturedView.as_view()), ]
from django.conf.urls import patterns, include, url from products.views import ProductList,ProductView, ProductCreate, ProductUpdate, delete_product from django.contrib.auth.decorators import login_required, permission_required urlpatterns = patterns('', #List view url(r'^$', login_required(ProductList.as_view()), name='product_list'), url('^(?P<pk>\d+)/$', ProductView.as_view(), name='product_details'), url('^create/$', ProductCreate.as_view(), name='product_create'), url(r'^(?P<pk>\d+)/update/$', ProductUpdate.as_view(), name='product_update'), url(r'^(?P<product_id>\d+)/delete$', delete_product, name='product_delete'), )
from django.urls import path from products.views import ProductView, ProductCreate, ProductList, ProductUpdate, ProductDelete app_name = "products" urlpatterns = [ path("products/", ProductList.as_view(), name="list"), path("products/create/", ProductCreate.as_view(), name="create"), path("products/<pk>/edit/", ProductUpdate.as_view(), name="edit"), path("products/<pk>/delete/", ProductDelete.as_view(), name="delete"), path("products/<pk>/", ProductView.as_view(), name="view"), path("", ProductList.as_view(), name="list"), ]
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.conf.urls.static import static from django.contrib import admin from django.urls import path from core.views import HomeView, PatientView from patients.views import current_datetime, HomepageView from check.views import PatientTemperatureView from products.views import ProductView urlpatterns = [ path("", HomeView.as_view(), name="dashboard"), path("patient/", PatientView.as_view(), name="patient"), path("product/", ProductView.as_view(), name="product"), path('admin/', admin.site.urls), path("simple/", current_datetime), path("home-old", HomepageView.as_view()), path("temperature/", PatientTemperatureView.as_view()), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # https://docs.djangoproject.com/en/3.0/howto/static-files/
from django.conf.urls import patterns, include, url from django.contrib import admin from django.conf.urls.static import static from django.conf import settings from products.views import ProductView admin.autodiscover() urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url(r'^$', ProductView.as_view(), name='index'), url(r'^api/', include('api.urls')), url(r'^logout/$', 'products.views.auth_logout', name='logout'), url(r'^login/$', 'products.views.auth_login', name='login'), url(r'^register/$', 'products.views.register', name='register'), ) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
from django.urls import path from products.views import (CategoriesView, ProductsView, ProductView, ChangeOfferView, FavoriteProductsView, RemoveFavoriteView, AddFavoriteView, ProductsJsonView) urlpatterns = [ path('categories/', CategoriesView.as_view(), name='categories'), path('products/', ProductsView.as_view(), name='products'), path('favorite-products/', FavoriteProductsView.as_view(), name='favorite_products'), path('add-favorite/', AddFavoriteView.as_view(), name='add_favorite'), path('remove-favorite/', RemoveFavoriteView.as_view(), name='remove_favorite'), path('products/<product_slug>/', ProductView.as_view(), name='product'), path('change-offer/', ChangeOfferView.as_view(), name='change_offer'), path('products.json/', ProductsJsonView.as_view(), name='products_json'), ]
from django.conf import settings from django.conf.urls.static import static from django.urls import path, reverse from products.views import (HomeView, ProductView, ShopView, add_to_cart, CheckoutView, login, sign_up, AddCouponView, OrderSummaryView, remove_from_cart, remove_single_item_from_cart) #from.import views app_name = 'products' urlpatterns = [ path('', HomeView.as_view(), name='home'), path('product', ShopView.as_view(), name='product'), path('order-summary/', OrderSummaryView.as_view(), name='order-summary'), path('product/<slug>/', ProductView.as_view(), name='pro'), # Here this detail view is work path('add-to-cart/<slug>/', add_to_cart, name='add-to-cart'), path('add-coupon/', AddCouponView.as_view(), name='add-coupon'), path('checkout/', CheckoutView.as_view(), name='checkout'), path('remove-from-cart/<slug>/', remove_from_cart, name='remove-from-cart'), path('remove-item-from-cart/<slug>/', remove_single_item_from_cart, name='remove-single-item-from-cart'), # path('go', login.as_view(), name='log'), path('sign-up', sign_up.as_view(), name='cart-list'), ]
from django.urls import path, include from products.views import ProductView, CategoryView urlpatterns = [ path('/product', ProductView.as_view()), path('/category', CategoryView.as_view()) ]
"""django_tutorial URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/3.1/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 products.views import ProductView urlpatterns = [ path('admin/', admin.site.urls), path('products/', ProductView.as_view()), path('products/<int:pk>', ProductView.as_view()), ]