Weird haystack importerror (only in production)

Tags: django

Last thursday, 30 December, I updated a site at 16:30. Normally, updating a site at such an hour is a standing invitation to Murphy for wreaking havoc. But this was “just a small update”, so I was fine, right?

Boom. In my, mod_wsgi complained:

Traceback (most recent call last):
    from haystack import indexes
ImportError: cannot import name indexes

What? It worked fine just before. Nothing related to any imports seemed to have changed. In any case not in the, settings,py or that An obvious candidate for such an error is a circular import, but I couldn’t find any.

Today, I googled and found one page: a closed haystack issue. I couldn’t destill a clear reason for the failure from the discussion there, to be honest. Race condition, apparently? Perhaps a hidden circular dependency through 4 different levels? I don’t know.

Anyway, the temporary solution is to do haystack’s autodiscovering not in an, but to put the:

import haystack

into your instead. I did it and that worked. But it doesn’t sit well with me. It seems to work and there’s a deadline next week, so I’ll leave it this way for now. But I sure hope someone replies on the ticket :-)

Well, it isn't a haystack, but at least it is grain :-) logo

About me

My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.

Weblog feeds

Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):