Answer the question
In order to leave comments, you need to log in
How to rewrite Django AnonymousUser using DRF?
We need to rewrite the anonymous user in Django. I used the django-custom-anonymous
library , everything works.
But the problem is that when a class or function with Django rest framework
from rest_framework.views import APIView
class AnonymousUserAPI(APIView):
def get(self, request):
print(request.user.__class__)
return Response(status=200)
from django.http import HttpResponse
def test(request):
print(request.user.__class__)
print(request.user.profile)
return HttpResponse(content=request)
Answer the question
In order to leave comments, you need to log in
I am not familiar with the library, but in the general case, when the user model is rewritten, you need to specify it in the settings.
In the case of DRF and Anonymous, the idea is so .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question