Skip to content

[FEATURE]: support using get_serializer_class on view #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion example/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ class BlogViewSet(viewsets.ModelViewSet):

class EntryViewSet(viewsets.ModelViewSet):
queryset = Entry.objects.all()
serializer_class = EntrySerializer
resource_name = 'posts'

def get_serializer_class(self):
return EntrySerializer


class AuthorViewSet(viewsets.ModelViewSet):
queryset = Author.objects.all()
Expand Down
2 changes: 1 addition & 1 deletion rest_framework_json_api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def validate_path(serializer_class, field_path, path):
included_resources = include_resources_param.split(',')
for included_field_name in included_resources:
included_field_path = included_field_name.split('.')
this_serializer_class = view.serializer_class
this_serializer_class = view.get_serializer_class()
# lets validate the current path
validate_path(this_serializer_class, included_field_path, included_field_name)

Expand Down