-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: simple api/v3/person/{id} endpoint
- Loading branch information
1 parent
5306f4c
commit e05c224
Showing
3 changed files
with
31 additions
and
0 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
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,15 @@ | ||
# Copyright The IETF Trust 2024, All Rights Reserved | ||
"""DRF API Views""" | ||
|
||
from rest_framework import mixins, viewsets | ||
|
||
from .models import Person | ||
|
||
|
||
class PersonViewSet(mixins.RetrieveModelMixin, viewsets.GenericViewSet): | ||
"""Person viewset | ||
Mostly demo for now. Only allows retrieving single instances. Think hard about permissions before | ||
allowing write or list access. | ||
""" | ||
queryset = Person.objects.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright The IETF Trust 2024, All Rights Reserved | ||
"""DRF Serializers""" | ||
|
||
from rest_framework import serializers | ||
|
||
from .models import Person | ||
|
||
|
||
class PersonSerializer(serializers.ModelSerializer): | ||
"""Person serializer""" | ||
|
||
class Meta: | ||
model = Person | ||
fields = ["id", "name"] |