Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haystack incompatible with Django 1.4?

I just upgradated my django to 1.4. I am getting trouble with haystack app. Also, I tried to update haystack to last stable version but I still having problems. Does anyone had theses errors? How can I solve it?

I am getting the following errors.

When I access any page:

cannot import name MAX_SHOW_ALL_ALLOWED haystack\admin.py in <module>, line 2

and

# python manage.py rebuild_index
django.core.exceptions.ImproperlyConfigured: Error importing template source loader
django.template.loaders.app_directories.load_template_source:
    "'module' object has no attri bute 'load_template_source'"

Thanks

like image 903
Thomas Avatar asked Apr 01 '12 01:04

Thomas


1 Answers

there is a problem in haystack/admin.py file. Try to do the following:

  1. remove import for MAX_SHOW_ALL_ALLOWED
  2. before class SearchChangeList add method:

    def list_max_show_all(changelist):
        """
        Returns the maximum amount of results a changelist can have for the
        "Show all" link to be displayed in a manner compatible with both Django
        1.4 and 1.3. See Django ticket #15997 for details.
        """
        try:
            # This import is available in Django 1.3 and below
            from django.contrib.admin.views.main import MAX_SHOW_ALL_ALLOWED
            return MAX_SHOW_ALL_ALLOWED
        except ImportError:
            return changelist.list_max_show_all
    
  3. in SearchChangeList.get_results() change can_show_all to

    can_show_all = result_count <= list_max_show_all(self)
    

Check this thread for more background info on the issue.

like image 126
szaman Avatar answered Sep 16 '22 20:09

szaman