Commit 56a6e4eb authored by Daniel W Bond's avatar Daniel W Bond
Browse files

added additional serializer to support hyperlinked serialization on major objects in the api

parent 3c51b140
......@@ -105,3 +105,13 @@ class MajorSerializer(serializers.ModelSerializer):
class Meta:
model = Major
fields = ('name', )
class MajorURLSerializer(serializers.ModelSerializer):
class Meta:
model = Major
fields = ('url', 'name')
extra_kwargs = {
'url': {'view_name': 'api_detail_major', 'lookup_field': 'slug'}
......@@ -13,7 +13,7 @@ from housing.models import Building, Floor, Room
from accounts.models import Major
from .serializers import (BuildingSerializer, BuildingFloorListSerializer,
FloorSerializer, RoomSerializer,
MajorSerializer, MajorURLSerializer)
# pagination class for optional inheritance
......@@ -80,7 +80,7 @@ class RoomRetrieve(MultipleFieldLookupMixin, RetrieveAPIView):
# major apis
class MajorList(ListAPIView):
queryset = Major.objects.all()
serializer_class = MajorSerializer
serializer_class = MajorURLSerializer
class MajorRetrieve(RetrieveAPIView):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment