I'm developing a todo API with Django. I am getting an error as ToDoView(view class name) should include serializer_class but I already have it. Here is the code
Router and URL
router = routers.DefaultRouter()
router.register(r'todo', views.ToDOView ,'todo')
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include(router.urls))
]
View:
class ToDOView(viewsets.ModelViewSet):
serializer_class: ToDOserializer
queryset = ToDo.objects.all()
serializers:
class ToDOserializer(serializers.ModelSerializer):
class Meta:
model : ToDo
fields : ('id','title','description','completed')
id, title, description and completed are fields of my model
Error: Get this error.
AssertionError at /api/todo/ 'ToDOView' should either include a
serializer_class
attribute, or override theget_serializer_class()
method