python - Django : TokenAuthentication, setting permissions on endpoints -


i using django rest framework build api , quite new it.

i set tokenauthentication method, , trying filter result of queryset depending on token.

basically, have endpoint (let's "/wallet"), , want /wallet endpoint give wallet of specific user sending query.

my approach redefine get_queryset method in viewset can't figure out how token, , how filter results.

also, anynomous users shouldn't allowed access endpoint.

here viewset, think need customisation here :

class walletviewset(viewsets.modelviewset):     """     api endpoint allows wallets viewed or edited.     """     queryset = wallet.objects.filter()     serializer_class = walletserializer 

my approach redefine get_queryset method in viewset can't figure out how token, , how filter results.

django rest framework tokenauthentication linked user. therefore advice filter against user should available in view through self.request.user

also, anynomous users shouldn't allowed access endpoint.

check permission section of documentation that.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -