Skip to content

Commit 51c83a5

Browse files
committed
add session
1 parent c11620e commit 51c83a5

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

db.sqlite3

0 Bytes
Binary file not shown.

project/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# SECURITY WARNING: don't run with debug turned on in production!
2626
DEBUG = True
2727

28-
ALLOWED_HOSTS = ['localhost', 'testserver']
28+
ALLOWED_HOSTS = ['localhost', 'testserver',"*"]
2929

3030

3131
REST_FRAMEWORK = {

rest_api/views.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
from rest_framework import generics, permissions
1+
from rest_framework import generics
22
from .permissions import IsOwner
33
from .serializers import BucketlistSerializer, UserSerializer
44
from .models import Bucketlist
55
from django.contrib.auth.models import User
6-
7-
6+
from rest_framework.permissions import IsAuthenticated
7+
from rest_framework.authentication import SessionAuthentication
88
class CreateView(generics.ListCreateAPIView):
99
"""This class handles the GET and POSt requests of our rest api."""
1010
queryset = Bucketlist.objects.all()
1111
serializer_class = BucketlistSerializer
12-
permission_classes = (
13-
permissions.IsAuthenticated,
14-
IsOwner)
12+
permission_classes = [IsAuthenticated]
13+
authentication_classes = [SessionAuthentication]
1514

1615
def perform_create(self, serializer):
1716
"""Save the post data when creating a new bucketlist."""
@@ -23,18 +22,19 @@ class DetailsView(generics.RetrieveUpdateDestroyAPIView):
2322

2423
queryset = Bucketlist.objects.all()
2524
serializer_class = BucketlistSerializer
26-
permission_classes = (
27-
permissions.IsAuthenticated,
28-
IsOwner)
29-
25+
permission_classes = [IsAuthenticated]
26+
authentication_classes = [SessionAuthentication]
3027

3128
class UserView(generics.ListAPIView):
3229
"""View to list the user queryset."""
3330
queryset = User.objects.all()
3431
serializer_class = UserSerializer
35-
32+
permission_classes = [IsAuthenticated]
33+
authentication_classes = [SessionAuthentication]
3634

3735
class UserDetailsView(generics.RetrieveAPIView):
3836
"""View to retrieve a user instance."""
3937
queryset = User.objects.all()
4038
serializer_class = UserSerializer
39+
permission_classes = [IsAuthenticated]
40+
authentication_classes = [SessionAuthentication]

0 commit comments

Comments
 (0)