Add urls for market app

This commit is contained in:
jhyns 2023-05-03 14:09:55 +09:00
parent 42deebb758
commit 572c7780af
2 changed files with 18 additions and 1 deletions

View File

@ -15,8 +15,9 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import include, path
urlpatterns = [ urlpatterns = [
path("admin/", admin.site.urls), path("admin/", admin.site.urls),
path("", include("market.urls")),
] ]

16
market/urls.py Normal file
View File

@ -0,0 +1,16 @@
from django.conf import settings
from rest_framework import routers
from .viewsets import BrandViewset, PostViewset, ProductViewset
if settings.DEBUG:
router = routers.DefaultRouter()
else:
router = routers.SimpleRouter()
router.register("brands", BrandViewset)
router.register("products", ProductViewset)
router.register("posts", PostViewset)
urlpatterns = router.urls