Haystack与Django 1.4不兼容?

Tho*_*mas 7 django django-haystack

我刚刚将我的django升级到了1.4.我在干草堆应用程序遇到麻烦.此外,我试图更新haystack到最后的稳定版本,但我仍然有问题.有没有人有这些错误?我该如何解决?

我收到以下错误.

当我访问任何页面时:

cannot import name MAX_SHOW_ALL_ALLOWED haystack\admin.py in <module>, line 2
Run Code Online (Sandbox Code Playgroud)

# 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'"
Run Code Online (Sandbox Code Playgroud)

谢谢

sza*_*man 6

haystack/admin.py文件中存在问题.尝试执行以下操作:

  1. 删除导入 MAX_SHOW_ALL_ALLOWED
  2. 课前SearchChangeList添加方法:

    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
    
    Run Code Online (Sandbox Code Playgroud)
  3. SearchChangeList.get_results()变化can_show_all

    can_show_all = result_count <= list_max_show_all(self)
    
    Run Code Online (Sandbox Code Playgroud)

请查看此主题以获取有关该问题的更多背景信息.

  • 请注意,此更改包含在Haystack 1.2.7中. (6认同)