I created an API with DRF and Knox and, I am using token based authentication. Everything is working except the system is showing the logged in user as anonymous.
I tried all this:
current_user = request.user
print(current_user.is_anonymous) # True
print(current_user.is_authenticated) # False
print(current_user.is_staff) # False
print(current_user.is_superuser) # false
print(current_user.is_active) # false
u = User()
print(u.id) # None
I need the user id of the logged in user because I am using that as a foreign key in the other table. I checked the auth_user table and it has all the columns. Is there any way to get the user id or convert the anonymous user to authenticated user ?
Thanks AJ