Skip to content

Instantly share code, notes, and snippets.

View jsmedmar's full-sized avatar

Juan Medina jsmedmar

View GitHub Profile
@jsmedmar
jsmedmar / token.py
Last active October 23, 2021 10:30
A django LoginRequiredMixin that allows token authentication.
from django.contrib.auth import mixins
from rest_framework.authentication import SessionAuthentication
from rest_framework.authentication import TokenAuthentication
from rest_framework import generics
class TokenLoginRequiredMixin(mixins.LoginRequiredMixin):
"""A login required mixin that allows token authentication."""
def dispatch(self, request, *args, **kwargs):