获得“str”没有属性“_default_manager”在刚刚启动的Django应用程序上 [英] Getting the "str" has no property "_default_manager" on a Django app just on startup

查看:184
本文介绍了获得“str”没有属性“_default_manager”在刚刚启动的Django应用程序上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我重新启动Apache以接管新的Django更改之后,我可能会在30秒钟之内收到以下错误:



ViewDoesNotExist:在模块project.app.views中尝试了home_page。错误是:'str'对象没有属性'_default_manager'



错误消失了一点,但它是非常奇怪的。任何想法如何调试或可能导致它?

解决方案

我认为这是这个错误:



http://code.djangoproject.com/ticket/ 10405#评论:11



似乎完美契合考虑到谷歌搜索不会显示很多,而且你的问题在一段时间后就消失了 - 根据由于懒惰加载模型字符串,这张票由



该评论建议在管理员自动发现功能之​​前添加以下内容。



来自django.db.models.loading导入缓存的$ code> $ c $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ code>


Right after I restart Apache to pick up the new Django changes, I get the following errors for probably 30 seconds to a minute afterwards:

ViewDoesNotExist: Tried home_page in module project.app.views. Error was: 'str' object has no attribute '_default_manager'

The errors go away after a bit, but it's very odd. Any idea how to debug this or what might be causing it?

解决方案

I think it's this bug:

http://code.djangoproject.com/ticket/10405#comment:11

Seems like a perfect fit considering google searches don't show much else, and that your problem goes away after some time - according to this ticket due to lazy loading of model strings.

The comment suggests adding the following before your admin autodiscover function.

from django.db.models.loading import cache as model_cache
if not model_cache.loaded:
    model_cache.get_models()

这篇关于获得“str”没有属性“_default_manager”在刚刚启动的Django应用程序上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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