diff --git a/config/urls.py b/config/urls.py index 425e343..92decab 100644 --- a/config/urls.py +++ b/config/urls.py @@ -15,8 +15,9 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.contrib import admin -from django.urls import path +from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), + path("", include("market.urls")), ] diff --git a/market/urls.py b/market/urls.py new file mode 100644 index 0000000..e75c1e2 --- /dev/null +++ b/market/urls.py @@ -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