Fix bookmarks api routes
This commit is contained in:
@@ -3,7 +3,7 @@ from rest_framework import routers
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
router = routers.DefaultRouter()
|
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.
|
# Wire up our API using automatic URL routing.
|
||||||
# Additionally, we include login URLs for the browsable API.
|
# Additionally, we include login URLs for the browsable API.
|
||||||
|
|||||||
@@ -4,5 +4,10 @@ from . import models
|
|||||||
from bookmarks.models import Bookmark
|
from bookmarks.models import Bookmark
|
||||||
|
|
||||||
class BookmarkViewSet(viewsets.ModelViewSet):
|
class BookmarkViewSet(viewsets.ModelViewSet):
|
||||||
queryset = Bookmark.objects.all()
|
|
||||||
serializer_class = models.BookmarkSerializer
|
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)
|
||||||
|
|||||||
@@ -129,5 +129,7 @@ REST_FRAMEWORK = {
|
|||||||
# or allow read-only access for unauthenticated users.
|
# or allow read-only access for unauthenticated users.
|
||||||
'DEFAULT_PERMISSION_CLASSES': [
|
'DEFAULT_PERMISSION_CLASSES': [
|
||||||
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'
|
||||||
]
|
],
|
||||||
|
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
|
||||||
|
'PAGE_SIZE': 100
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user