2012-04-01 61 views
7

我刚把我的django升级到了1.4。我在干草堆应用程序中遇到了麻烦。此外,我试图更新干草堆上次稳定版本,但我仍然有问题。有没有人有这些错误?我该如何解决它?Haystack与Django 1.4不兼容?

我收到以下错误。

当我访问任何网页:

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

# 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'" 

感谢

回答

6

存在草垛/ admin.py文件有问题。尽量做到以下几点:

  1. 删除进口的MAX_SHOW_ALL_ALLOWED
  2. 课前SearchChangeList add方法:

    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. SearchChangeList.get_results()变化can_show_all

    can_show_all = result_count <= list_max_show_all(self) 
    

检查this thread以获得有关此问题的更多背景信息。

+0

这需要修改草垛虽然:( – Geekfish 2012-04-03 11:09:03

+0

但是我把答案的链接是这种解决方案的叉。 – szaman 2012-04-04 05:57:45

+0

那是一个可惜的是这个代码仍然在分支(wasnt致力于为最后一个版本)。 – Thomas 2012-04-04 11:54:49