-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72f3bdc
commit e77b9ed
Showing
3 changed files
with
33 additions
and
11 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from rest_framework import serializers | ||
from .models import Category | ||
|
||
class CategorySerializer(serializers.ModelSerializer): | ||
|
||
class Meta: | ||
model = Category | ||
fields = "__all__" |
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
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,12 +1,8 @@ | ||
from rest_framework.decorators import api_view | ||
from rest_framework.response import Response | ||
from rest_framework.viewsets import ModelViewSet | ||
from .models import Category | ||
from .serializers import CategorySerializer | ||
|
||
@api_view() | ||
def categories(request): | ||
return Response( | ||
{ | ||
"ok": True, | ||
"categories": Category.objects.all() | ||
} | ||
) | ||
class CategoryViewSet(ModelViewSet): | ||
|
||
serializer_class = CategorySerializer | ||
queryset = Category.objects.all() |