Django ver 1.7 AppRegistryNotReady:模型尚未加载 [英] Django ver 1.7 AppRegistryNotReady: Models aren't loaded yet

查看:114
本文介绍了Django ver 1.7 AppRegistryNotReady:模型尚未加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过认证教程来确保一切正常工作。
我输入了以下代码。

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() for ForeignKey related managers changed from a series of Model.save() calls to a single QuerySet.update() call. The change means that pre_save and post_save signals aren’t sent anymore. You can use the bulk=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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆