Django ver 1.7 AppRegistryNotReady:模型尚未加载 [英] Django ver 1.7 AppRegistryNotReady: Models aren't loaded yet
问题描述
我正在尝试通过认证教程来确保一切正常工作。
我输入了以下代码。
I am trying to work through the authentication tutorials to make sure everything works as expected. I entered the following code.
>>> from django.contrib.auth.models import User
>>> user = User.objects.create_user('john', 'lennon@thebeatles.com', 'johnpassword')
>>> user.last_name = 'Lennon'
>>> user.save()
我收到错误
AppRegistryNotReady: Models aren't loaded yet.
我从发行说明中看到
$($)code> foreignKey
相关的
管理员的默认实现为一系列Model.save()
调用单个
QuerySet.update()
调用。更改意味着不再发送pre_save
和post_save
信号。您可以使用bulk = False
关键字
参数恢复以前的行为。
The default implementation of
remove()
forForeignKey
related managers changed from a series ofModel.save()
calls to a singleQuerySet.update()
call. The change means thatpre_save
andpost_save
signals aren’t sent anymore. You can use thebulk=False
keyword argument to revert to the previous behaviour.
所以我认为这是一个外键问题。
So I presume it is a foreign key issue.
我的问题是,我在哪里使用 bulk = False
属性还是有其他解决方案?
My question is, where do I use the bulk=False
attribute or is there another solution?
推荐答案
我建议在您的代码之前执行此操作:
I suggest doing this before your code above:
import django
django.setup()
是否修复?
这篇关于Django ver 1.7 AppRegistryNotReady:模型尚未加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!