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

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

问题描述

在我重新启动 Apache 以获取新的 Django 更改后,我在大约 30 秒到一分钟内收到以下错误:

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:在模块 project.app.views 中尝试过 home_page.错误是:'str' 对象没有属性 '_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?

推荐答案

我认为是这个错误:

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天全站免登陆