How to show content only to user that created it?
Question:
I have program like todo list. And I need to filter db to show only content that user created
I have code like this:
name = Gift.objects.filter(author=request.user)
But it show error
Cannot resolve keyword 'author' into field. Choices are: gift_name, id, person_name, user, user_id
Answers:
Try this:
Also it is mentioned in the warning to use which attriubutes as a hint.
since author is not preset you have to use user
name = Gift.objects.filter(user=request.user)
I have program like todo list. And I need to filter db to show only content that user created
I have code like this:
name = Gift.objects.filter(author=request.user)
But it show error
Cannot resolve keyword 'author' into field. Choices are: gift_name, id, person_name, user, user_id
Try this:
Also it is mentioned in the warning to use which attriubutes as a hint.
since author is not preset you have to use user
name = Gift.objects.filter(user=request.user)