Closed Westlifers closed 1 year ago
sorry, I didn't fully understand the documentation. This can be solved by using AllowGuestUserMixin:
class GuestUserLogin(AllowGuestUserMixin, GenericAPIView):
permission_classes = [permissions.AllowAny]
def get(self, request):
username = request.user.username
return JsonResponse({'detail': f'Guest user login success!{username}'})
my bad :(
Hi @Westlifers thank you for creating this issue! Glad you were able to find the issue yourself. I think I can improve the error message a bit in this case when using a decorator on a view class in the future.
Hello, I'm trying to apply this package in my project, but I'm stuck here When I visit an API with @allow_guest_user above the get method:
and if I visit this API by router
path('guestlogin/', GuestUserLogin.as_view()),
, it returns an error:However, 'django.contrib.sessions' do exist in INSTALLED_APPS:
I tried to move it to the top or the bottom of INSTALLED_APPS but neither worked. If I remove the decorator @allow_guest_user, it worked well(with a real user logged in)
My Django version: 4.2.4 Python version: 3.11.1