Getting the “str” has no property “_default_manage

2020-02-05 11:29发布

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?

1条回答
家丑人穷心不美
2楼-- · 2020-02-05 12:00

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()
查看更多
登录 后发表回答