William Luky
William Luky

Reputation: 25

Django Authentication and Permissions: Snippets visible only to the creator

So in the tutorial for authentication and permissions:

http://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/

All user can see all snippets but it only allows the user to edit their own snippets.

But I want to tweak the program a little bit into:

The user can only see their own snippets. Snippets that are created by others are not visible.

Is this possible?

Upvotes: 2

Views: 148

Answers (1)

slider
slider

Reputation: 12990

Yes, it's possible. Take a look at filtering querysets. In short, you'll have to write your own get_queryset method to only return results associated with the logged in user.

Upvotes: 2

Related Questions