Getting the “str” has no property “_default_manager” on a Django app just on startup

前端 未结 2 447
独厮守ぢ
独厮守ぢ 2020-12-10 09:08

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: Tr

相关标签:
2条回答
  • 2020-12-10 09:20

    I am newbie to Django python, my mistake was in view.py, model part

    model = ‘Article'

    ArticleListViews(ListView):
        model = 'Article'
        template_name = ‘article.html'
    

    it raise same error. model = Article is correct. I don’t need to put the name of model in quotations.

    enjoy coding.

    0 讨论(0)
  • 2020-12-10 09:33

    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()
    
    0 讨论(0)
提交回复
热议问题