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/)更好地解釋它,然後我就可以。祝你好運,請接受回答你的問題的答案! –