4

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?

Bialecki
  • 30,061
  • 36
  • 87
  • 109
  • 1
    `_default_manager` is an attribute of a model class. Any 'str' you object in your view which you are using as a model class by mistake? Maybe you add some code of view here. – Torsten Engelbrecht Apr 25 '11 at 04:45

2 Answers2

9

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()
Yuji 'Tomita' Tomita
  • 115,817
  • 29
  • 282
  • 245
  • 2
    Definitely seems like this is the problem, thanks, I think that'll do the trick. As a note for later, my issue isn't related to the admin.autodiscover() bit, but it does occur with ModelForm imports. Thanks! – Bialecki Apr 25 '11 at 05:50
1

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.

ila idamas
  • 11
  • 1