mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 00:04:16 +03:00
Change serializers.Field to serializers.ReadOnlyField for 3.x compatibility
Using this code snippet as-is on DRF 3.0.1 results in a NotImplementedError being raised for to_representation due to 3.0's changed behavior with serializers.Field. The code snippet should be updated to use serializers.ReadOnlyField instead. Further discussion here: https://groups.google.com/forum/?fromgroups=#!topic/django-rest-framework/aX8mLT_v3yc
This commit is contained in:
parent
dd712a1c26
commit
2d470eef80
|
@ -128,7 +128,7 @@ For example, to nest a pair of links labelled 'prev' and 'next', and set the nam
|
|||
|
||||
class CustomPaginationSerializer(pagination.BasePaginationSerializer):
|
||||
links = LinksSerializer(source='*') # Takes the page object as the source
|
||||
total_results = serializers.Field(source='paginator.count')
|
||||
total_results = serializers.ReadOnlyField(source='paginator.count')
|
||||
|
||||
results_field = 'objects'
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user