I am trying to call User.objects.get(pk=1)
, but I am getting this error message:
我试图调用User.objects.get(pk = 1),但我收到此错误消息:
File "C:\Project\Project\env\lib\site-packages\django\apps\registry.py", line 131, in check_models_ready raise AppRegistryNotReady("Models aren't loaded yet.") AppRegistryNotReady: Models aren't loaded yet.
文件“C:\ Project \ Project \ env \ lib \ site-packages \ django \ apps \ registry.py”,第131行,在check_models_ready中引发AppRegistryNotReady(“模型尚未加载。”)AppRegistryNotReady:模型不是装了。
I am able to call User.objects.all()
successfully.
我能够成功调用User.objects.all()。
What's missing? Thanks
少了什么东西?谢谢
1 个解决方案
#1
1
I am answering my own question. I had to call django.setup() in the interactive Python shell.
我在回答我自己的问题。我不得不在交互式Python shell中调用django.setup()。
import django
django.setup()
#1
1
I am answering my own question. I had to call django.setup() in the interactive Python shell.
我在回答我自己的问题。我不得不在交互式Python shell中调用django.setup()。
import django
django.setup()