Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django.contrib.auth.models.DoesNotExist: User matching query does not exist

I tried to create an instance of a user in python shell using the following commands.

from django.contrib.auth.models import User
User.objects.all()
<QuerySet [<User: admin>]>
me = User.objects.get(username='rohan')

After which I got the following errors. Can someone please help.

 Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "C:\Users\Rohan Jain\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
        return getattr(self.get_queryset(), name)(*args, **kwargs)
      File "C:\Users\Rohan Jain\AppData\Local\Programs\Python\Python36\lib\site-packages\django\db\models\query.py", line 380, in get
        self.model._meta.object_name
    django.contrib.auth.models.DoesNotExist: User matching query does not exist.
like image 327
Rohan Jain Avatar asked May 15 '26 03:05

Rohan Jain


1 Answers

You have no User with username rohan. You seems to have a user with username admin though.

me = User.objects.get(username='admin')
like image 52
D.Nibon Avatar answered May 17 '26 16:05

D.Nibon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!