Exemplo n.º 1
0
from django.urls import path
from api.views import CategoryViewSet, ProductListAPIView, ProductDetailAPIView, CommentViewSet, product_comment, \
    category_product
from rest_framework import routers

router = routers.SimpleRouter()
router.register('categories', CategoryViewSet, basename='api')
router.register('comments', CommentViewSet, basename='api')
# router.register('products', ProductAPIView, basename='api')

urlpatterns = [
    path('products/', ProductListAPIView.as_view()),
    path('products/<int:pk>/', ProductDetailAPIView.as_view()),
    path('products/<int:pk>/comments/', product_comment),
    path('categories/<int:pk>/products/', category_product),
]

urlpatterns += router.urls
Exemplo n.º 2
0
    url(regex=r'^token-auth/', view=obtain_jwt_token),
    url(regex=r"^(?P<version>(v1))/lots/(?P<pk>[0-9]+)/",
        view=LotDetailAPIView.as_view(),
        name="lot-detail"),
    url(regex=r"(?P<version>(v1))/lots/search/?$",
        view=LotSearchAPIView.as_view(),
        name="lot-search"),
    url(regex=r"(?P<version>(v1))/lots/",
        view=LotListAPIView.as_view(),
        name="lot-list"),
    url(regex=r"^(?P<version>(v1))/brands/(?P<pk>[0-9]+)/",
        view=BrandDetailAPIView.as_view(),
        name="brand-detail"),
    url(regex=r"(?P<version>(v1))/brands/search/?$",
        view=BrandSearchAPIView.as_view(),
        name="brand-search"),
    url(regex=r"(?P<version>(v1))/brands/",
        view=BrandListAPIView.as_view(),
        name="brand-list"),
    url(regex=r"^(?P<version>(v1))/products/(?P<pk>[0-9]+)/",
        view=ProductDetailAPIView.as_view(),
        name="product-detail"),
    url(regex=r"(?P<version>(v1))/products/search/?$",
        view=ProductSearchAPIView.as_view(),
        name="product-search"),
    url(regex=r"(?P<version>(v1))/products/",
        view=ProductListAPIView.as_view(),
        name="product-list"),
    url(regex=r'^', view=wrong_url),
]