Token matching query does not exist
Token is not automatically created after creating user or even superuser
I only noticed this after all the module 8 tests return error due to rest_framework.authtoken.models.Token.DoesNotExist: Token matching query does not exist.
It seems that the token is only created when manually triggering http://api:8000/api-token-auth/ and at this point I am still new to the whole thing. Can someone help me identify the root of the error? So far I am following the course to a T except I am using windows. My suspicion is the signals.py not working but I don't know what to do at the moment.
Hi.
Did it work when you followed the steps in module 5?
The signal may not be working. Double check ecommerce/app.py and ensure you have the following method:
def ready(self): import ecommerce.signals
Also double check that your directory set up matches the module guides.
Have you created a user in the admin ui & checked the token table?
Thanks
Bobby
Hi sir, thank you for your very quick response
So far the module 5 manage to return token after triggering api-token-auth manually, I do not understand is this how it is supposed to be or is the app supposed to make the token by itself after creating the user?
I have the import ecommerce.signals method in app.py
I have created a user and checked the token table like in module 5 and I can see the token in the database
I should double check first if I missed anything first, I will update if I find what I miss.
Also something that I tried outside of the course is I added print to def report_uploaded in signals.py manage.py test never do the print so can I assume that the function was never called?
I think I should also include that http://api:8000/item/ 'Authorization: Token your_token' does work when using the token created by the api-token-auth manually
I forgot to add that the error traceback from manage.py test on module 8 that I encounter is as follows for all the 10 functions
Traceback (most recent call last): File "...\drf_course\backend\ecommerce\tests.py", line 31, in setUp self.token = Token.objects.get(user=self.user) File "...drf_course\venv\lib\site-packages\django\db\models\manager.py", line 85, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "...drf_course\venv\lib\site-packages\django\db\models\query.py", line 650, in get raise self.model.DoesNotExist( rest_framework.authtoken.models.Token.DoesNotExist: Token matching query does not exist.