Skip to content

Commit

Permalink
Add author API with viewset and URL routing
Browse files Browse the repository at this point in the history
- Implemented a viewset for the Author model and connected it to API routes.
  • Loading branch information
vladyslav-tmf committed Nov 23, 2024
1 parent 4fa5159 commit 186a1f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 9 additions & 1 deletion author/urls.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from django.urls import path, include
from rest_framework import routers
from author import views


app_name = "author"

urlpatterns = []
router = routers.DefaultRouter()
router.register("authors", views.AuthorViewSet, basename="manage")

urlpatterns = [path("", include(router.urls))]
7 changes: 5 additions & 2 deletions author/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from rest_framework import viewsets

from author.models import Author
from author.serializers import AuthorSerializer


class AuthorViewSet(viewsets.ModelViewSet):
# write your code here
pass
queryset = Author.objects.all()
serializer_class = AuthorSerializer

0 comments on commit 186a1f8

Please sign in to comment.