Skip to content

Commit 984a280

Browse files
committed
Fixed a bug where previous_link was set to the value of previous
1 parent ec9aed8 commit 984a280

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ resource_name property
128128
^^^^^^^^^^^^^^^^^^^^^^
129129

130130
On resources that do not subclass ``rest_framework.viewsets.ModelViewSet``,
131-
the ``resource_name`` property is required on the class.::
131+
the ``resource_name`` property is required on the class::
132132

133133
class Me(generics.GenericAPIView):
134134
"""
@@ -147,7 +147,7 @@ Managing the trailing slash
147147

148148
By default Django expects a trailing slash on urls and will 301 redirect any
149149
requests lacking a trailing slash. You can change the server side by
150-
instantiating the Django REST Framework's router like so:::
150+
instantiating the Django REST Framework's router like so::
151151

152152
router = routers.SimpleRouter(trailing_slash=False)
153153

@@ -156,7 +156,7 @@ in Django's settings.py file and modify url pattern regex to match routes
156156
without a trailing slash.
157157

158158
If you prefer to make the change on the client side then add an
159-
application adapter to your Ember app and override the buildURL method:::
159+
application adapter to your Ember app and override the buildURL method::
160160

161161
App.ApplicationAdapter = DS.RESTAdapter.extend({
162162
buildURL: function() {

example/tests/test_model_viewsets.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def test_key_in_list_result(self):
4141
self.assertEquals(meta.get('count', 0),
4242
get_user_model().objects.count())
4343
self.assertEquals(meta.get("next"), 2)
44+
self.assertEqual('http://testserver/user-viewset/?page=2',
45+
meta.get("next_link"))
4446
self.assertEqual(meta.get("page"), 1)
4547

4648
def test_page_two_in_list_result(self):
@@ -65,7 +67,10 @@ def test_page_two_in_list_result(self):
6567
self.assertEquals(meta.get('count', 0),
6668
get_user_model().objects.count())
6769
self.assertIsNone(meta.get("next"))
70+
self.assertIsNone(meta.get("next_link"))
6871
self.assertEqual(meta.get("previous"), 1)
72+
self.assertEqual('http://testserver/user-viewset/?page=1',
73+
meta.get("previous_link"))
6974
self.assertEqual(meta.get("page"), 2)
7075

7176
def test_page_range_in_list_result(self):

rest_framework_ember/pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,6 @@ class EmberPaginationSerializer(pagination.BasePaginationSerializer):
7575
next_link = NextPageLinkField(source='*')
7676
page = PageField(source='*')
7777
previous = PreviousPageField(source='*')
78-
previous_link = PreviousPageField(source='*')
78+
previous_link = PreviousPageLinkField(source='*')
7979
count = serializers.Field(source='paginator.count')
8080

0 commit comments

Comments
 (0)