31 lines
749 B
Python
31 lines
749 B
Python
|
from rest_framework import routers, serializers, viewsets
|
||
|
|
||
|
from .models import Member, MemberFlag, Flag
|
||
|
|
||
|
|
||
|
class MemberSerializer(serializers.HyperlinkedModelSerializer):
|
||
|
class Meta:
|
||
|
model = Member
|
||
|
fields = "__all__"
|
||
|
|
||
|
|
||
|
class MemberViewSet(viewsets.ModelViewSet):
|
||
|
queryset = Member.objects.all()
|
||
|
serializer_class = MemberSerializer
|
||
|
|
||
|
|
||
|
class FlagSerializer(serializers.HyperlinkedModelSerializer):
|
||
|
class Meta:
|
||
|
model = Flag
|
||
|
fields = "__all__"
|
||
|
|
||
|
|
||
|
class FlagViewSet(viewsets.ModelViewSet):
|
||
|
queryset = Flag.objects.all()
|
||
|
serializer_class = FlagSerializer
|
||
|
|
||
|
|
||
|
router = routers.DefaultRouter()
|
||
|
router.register(r"membershipworks/member", MemberViewSet)
|
||
|
router.register(r"membershipworks/flag", FlagViewSet)
|