Answer the question
In order to leave comments, you need to log in
How to use authorization token in normal views?
Good afternoon!
vue+django client/server application
I have a custom view that allows users to like articles.
def article_like(request):
print(request.user)
print(request.headers['Authorization'])
return JsonResponse({'status': 'ok'})
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
),
}
Answer the question
In order to leave comments, you need to log in
No way.
Standard Django methods do not and cannot know what resources third-party modules operate on (at least not without crutches).
There is only one solution here - do not reinvent the wheel and use ready-made solutions from DRF.
If you really want to use "standard" views, then use Function Based Views
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question