1
votes

I'm actually looking for a way to implement.

I have a django project folder (only django, not django rest framework). All the views across all the apps in the project will be returning a JsonResponse parsed response. (Instead of rendering to a template)

A basic view looks like this, with necessary imports

from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_http_methods
from django.http import JsonResponse

@csrf_exempt
@require_http_methods(['POST'])
def sample_route(request):
    # validate request object, use them to query / process data 
    # .. some more statements
    result = {"a": 1, "b": 2}
    return JsonResponse(result, status=200)

I understand that this isn't a conventional practice like in a DRF project, but I would like to make such routes accessible by tokens (supposedly JWT). Can I get suggestions about how this would be possible - like with or without depending on djangorestframework library or any extensions or any other JWT associated libraries.

Thanks