def setUp(self): self.user = User.objects.create_user(username='******', email='*****@*****.**', password='******', first_name='Gabriel', last_name='RenĂ³', is_staff=True) self.factory = APIRequestFactory() self.view = ProductView.as_view() self.category = Category.objects.create(name='Prato') self.product = Product.objects.create(name='Product 1', description='Description 1', category=self.category) self.price = Price.objects.create(price=2.42, currency='BRL', product=self.product)
"""main URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/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 store.views import IndexView, StoreLoginView, StoreLogoutView, SectionView, ProductView, CartView, OrderView urlpatterns = [ path('admin/', admin.site.urls), path('', IndexView.as_view(), name='index'), path('login/', StoreLoginView.as_view(), name='login'), path('logout/', StoreLogoutView.as_view(), name='logout'), path('section/<int:pk>/', SectionView.as_view(), name='section'), path('product/<int:pk>/', ProductView.as_view(), name='product'), path('card/', CartView.as_view(), name='cart'), path('order/', OrderView.as_view(), name='order'), ]
from django.conf.urls import patterns, url from store.views import ProductView,ProductListView urlpatterns = patterns('', url(r'^product/(?P<pk>\d+)/$', ProductView.as_view(), name='product'), url(r'^product_list/$', ProductListView.as_view(), name='product_list'), )
from django.conf.urls import patterns, include, url from django.views.generic import TemplateView from store.views import CreateStoreView, DisplayStoreView, AuthView, ProductView # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^$', TemplateView.as_view(template_name="index.html"), name='homepage'), url(r'^createshop', CreateStoreView.as_view(), name='shop_create'), url(r'^auth', AuthView.as_view(), name='auth'), url(r'^product/(?P<pid>[0-9]+)/', ProductView.as_view(), name='product'), url(r'^store/(?P<storeid>[0-9]+)/', DisplayStoreView.as_view(), name='store'), # Examples: # url(r'^$', 'market.views.home', name='home'), # url(r'^market/', include('market.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), )
from django.conf.urls import patterns, url from store.views import ProductView, ProductListView urlpatterns = patterns( '', url(r'^product/(?P<pk>\d+)/$', ProductView.as_view(), name='product'), url(r'^product_list/$', ProductListView.as_view(), name='product_list'), )