Skip to content

Commit 2f1ddbb

Browse files
committed
imp: Chapter06
1 parent 75a99d2 commit 2f1ddbb

File tree

13 files changed

+19
-3
lines changed

13 files changed

+19
-3
lines changed
197 Bytes
Binary file not shown.
238 Bytes
Binary file not shown.
468 Bytes
Binary file not shown.
235 Bytes
Binary file not shown.
739 Bytes
Binary file not shown.
330 Bytes
Binary file not shown.
755 Bytes
Binary file not shown.
208 Bytes
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.urls import path
2+
from . import views
3+
4+
urlpatterns = [
5+
path('todos/', views.TodoList.as_view()),
6+
]
Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1-
from django.shortcuts import render
1+
from rest_framework import generics
2+
from .serializers import TodoSerializer
3+
from todo.models import Todo
24

3-
# Create your views here.
5+
class TodoList(generics.ListAPIView):
6+
# ListAPIView requires two mandatory attributes, serializer_class and # queryset.
7+
# We specify TodoSerializer which we have earlier implemented
8+
serializer_class = TodoSerializer
9+
10+
def get_queryset(self):
11+
user = self.request.user
12+
return Todo.objects.filter(user=user).order_by('-created')

0 commit comments

Comments
 (0)