#Sessions Django issue
1 messages · Page 1 of 1 (latest)
after login:
csrftoken o4EJRzQKrGLpoYx2DWzdXTdzKrOOiJeJ
sessionid yknaf26ewobrhpje96dd3cjv5mnap8ov
cookie
Headers for profile:
X-CSRFToken: o4EJRzQKrGLpoYx2DWzdXTdzKrOOiJeJ
Authorization: Basic yknaf26ewobrhpje96dd3cjv5mnap8ov
this is not correct
when you are using session auth Authorization header is not used for auth
but the sessionid cookie
you need to check the cookie, not Authorization header
i use Insomnia for testing
ok put the cookie in your header
correct
same problem
can you try it from a browser
I don't have authorization form
yes
login to admin page
and?
then go to this endpoint
@api_view(['GET'])
@permission_classes([IsAuthenticated])
def api_public_user_profile(request):
user = request.user
user_profile = PublicUser.objects.get(user=user.id)
serializer = PublicUserSerializer(user_profile)
return Response({'user': serializer.data}, status=status.HTTP_200_OK)
whatever the url is
you are not supposed to have multiple user models
I have 2 models
why?
if you want public/manager/freebie whatever, use permissions
because it will break things as you can see
I need to add other fields to this model and I have created a separate one
libraries use get_user_model to determine what user model is being used
then create your custom model?
where do I use "get_user_model"?
anytime when you need the user model
and maybe use one of the auth libraries along with drf to make things easier, dj-rest-auth, djoser etc
How do I use it if I need to use 2 models?
why do you need 2 models?
for admin panel and public site
admin panel access is determined by is_staff attribute of user model, when you create a user is_staff is False so user can't access admin anyway?
2 models cannot be used?
no, and you still didn't answer why you would need 2 models
Okay, I'll try, thanks