gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 09:18:03 24 4
gpt4 key购买 nike

我尝试使用以下命令在 python shell 中创建用户实例。

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

之后我得到了以下错误。有人可以帮忙吗。

 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.

最佳答案

你有no User with username rohan .不过,您似乎有一个用户名为 admin 的用户。

me = User.objects.get(username='admin')

关于django.contrib.auth.models.DoesNotExist : User matching query does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45657871/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com