0
我试图使用以下命令在python shell中创建用户实例。django.contrib.auth.models.DoesNotExist:用户匹配查询不存在
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.
好的!我是初学者,这是我的第一个Python项目。当我使用上述命令时,它究竟做了什么?你能解释一下吗? –
[本页](https://docs.djangoproject.com/en/1.11/topics/db/queries/)更好地解释它,然后我就可以。祝你好运,请接受回答你的问题的答案! –