Search code examples
djangodjango-rest-frameworkdjango-rest-framework-simplejwt

Django, jwt authentication in django view, not just DRF


I'd like to use jwt with django (probably https://github.com/davesque/django-rest-framework-simplejwt)

The library documentation and most web blogs on jwt talks about using jwt on DRF authentication.

But we have Django regular views which are not DRF based.

Can I still use one jwt authentication backend for both DRF and regular django views?


Solution

  • No, you cannot. DRF DEFAULT_AUTHENTICATION_CLASSES and Django AUTHENTICATION_BACKENDS handle auth in Session and Token-based respectively. Besides that, they are a different namespace.