How to create a seperate GET /all
API? Error: 'DjapyObjectJsonMapper' object has no attribute 'get'
#2
-
According to the code in Djapy-todo, @djapy_paginator([
'id', 'title', 'will_be_completed_at', 'created_at',
'user_id', 'username', 'user', 'completed_at'
], object_parser={
'user_id': lambda todo: todo.user.id,
'user': lambda todo: todo.user.username,
})
def todo_get(request, *args, **kwargs):
todos = Todo.objects.all()
todos = todos.filter(user=request.user).order_by('-completed_at')
return todos I tried creating seperate api path for path('todos/all/', plans_views.todo_get, name='todo-index'), It give me the error of But with the below code it works:
|
Beta Was this translation helpful? Give feedback.
Answered by
Bishwas-py
Sep 25, 2023
Replies: 1 comment 1 reply
-
Just try adding |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ikshyza
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just try adding
@node_to_json_response
on the top of@djapy_paginator([...