小编Roh*_*ain的帖子

django.contrib.auth.models.DoesNotExist:用户匹配查询不存在

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

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

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

 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.
Run Code Online (Sandbox Code Playgroud)

django django-models python-3.6

0
推荐指数
1
解决办法
4402
查看次数

标签 统计

django ×1

django-models ×1

python-3.6 ×1