-
Notifications
You must be signed in to change notification settings - Fork 442
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add author API with viewset and URL routing
- Implemented a viewset for the Author model and connected it to API routes.
- Loading branch information
1 parent
4fa5159
commit 186a1f8
Showing
2 changed files
with
14 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |