pythondjangoauthenticationdjango-rest-framework

how to retrieve the token generated while using django allauth and django-rest-auth with django rest framework


I am using django allauth and django-rest-auth from this tutorial to generate a token for django rest framework. The tutorial can be found on this page, at the bottom. (https://www.softcover.io/read/92780ad5/django_book/token_authentication)

I am able to generate the token after accessing api/dj-rest-auth/register/, which is the sign up page from the browsable API.

enter image description here

enter image description here

Now the issue is that i am on python3 manage.py shell and i am trying to retrieve any of the token generated for either user test001 or test002

does any one know how to do it? I am having a hardtime to achieve it

Thanks in advance


Solution

  • tokens_for_user1_and_user2 = APIToken.objects.filter(user__name__in=["test001","test002"]).all()
    

    I guess ... or something like that