diff --git a/apiv1/urls.py b/apiv1/urls.py index cfc37c4..d07f424 100644 --- a/apiv1/urls.py +++ b/apiv1/urls.py @@ -3,7 +3,7 @@ from rest_framework import routers from . import views router = routers.DefaultRouter() -router.register(r'bookmarks', views.BookmarkViewSet) +router.register(r'bookmarks', views.BookmarkViewSet, basename='bookmark') # Wire up our API using automatic URL routing. # Additionally, we include login URLs for the browsable API. diff --git a/apiv1/views.py b/apiv1/views.py index abe8aad..d50431c 100644 --- a/apiv1/views.py +++ b/apiv1/views.py @@ -4,5 +4,10 @@ from . import models from bookmarks.models import Bookmark class BookmarkViewSet(viewsets.ModelViewSet): - queryset = Bookmark.objects.all() serializer_class = models.BookmarkSerializer + + def perform_create(self, serializer): + serializer.save(user = self.request.user) + + def get_queryset(self): + return Bookmark.objects.filter(user=self.request.user) diff --git a/forgetmenot/settings.py b/forgetmenot/settings.py index 22fbeef..8fac521 100644 --- a/forgetmenot/settings.py +++ b/forgetmenot/settings.py @@ -129,5 +129,7 @@ REST_FRAMEWORK = { # or allow read-only access for unauthenticated users. 'DEFAULT_PERMISSION_CLASSES': [ 'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly' - ] + ], + 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', + 'PAGE_SIZE': 100 } \ No newline at end of file