Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
roomlist
Commits
56a6e4eb
Commit
56a6e4eb
authored
Sep 27, 2016
by
Daniel W Bond
Browse files
added additional serializer to support hyperlinked serialization on major objects in the api
parent
3c51b140
Changes
2
Hide whitespace changes
Inline
Side-by-side
roomlist/api/serializers.py
View file @
56a6e4eb
...
...
@@ -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'
}
}
roomlist/api/views.py
View file @
56a6e4eb
...
...
@@ -13,7 +13,7 @@ from housing.models import Building, Floor, Room
from
accounts.models
import
Major
from
.serializers
import
(
BuildingSerializer
,
BuildingFloorListSerializer
,
FloorSerializer
,
RoomSerializer
,
MajorSerializer
)
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
=
Major
URL
Serializer
class
MajorRetrieve
(
RetrieveAPIView
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment