foonpcf
V2EX  ›  Django

請問怎樣使用Django-haystack作搜尋器?

  •  
  •   foonpcf · Aug 28, 2013 · 4329 views
    This topic created in 4661 days ago, the information mentioned may be changed or developed.
    8 replies    1970-01-01 08:00:00 +08:00
    zhuf
        1
    zhuf  
       Aug 28, 2013   ❤️ 1
    foonpcf
        2
    foonpcf  
    OP
       Aug 28, 2013
    @zhuf, 當我python manage.py rebuild_index後出現這個情況“TypeError: coercing to Unicode: need string or buffer, tuple found“
    zhuf
        3
    zhuf  
       Aug 28, 2013
    @foonpcf 具体代码贴下
    foonpcf
        4
    foonpcf  
    OP
       Aug 28, 2013
    我是用Django-cms及django-cms-search, 需要倚賴Django-haystack

    settings.py

    HAYSTACK_SEARCH_ENGINE = 'whoosh'

    HAYSTACK_WHOOSH_PATH = os.path.join(os.path.dirname(__file__), 'whoosh_index'),

    HAYSTACK_SITECONF = 'cmsplugin_search.search_indexes'
    zhuf
        5
    zhuf  
       Aug 28, 2013   ❤️ 1
    @foonpcf 我记得文档里应该是这样的吧
    ```import os
    HAYSTACK_CONNECTIONS = {
    'default': {
    'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine',
    'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'),
    },
    }```
    zhuf
        6
    zhuf  
       Aug 28, 2013   ❤️ 1
    还有检查下haystack的版本,好像版本不对是有问题的。
    foonpcf
        7
    foonpcf  
    OP
       Aug 28, 2013
    版本是django-haystack 1.2.7
    foonpcf
        8
    foonpcf  
    OP
       Aug 29, 2013
    @zhuf, 我重新用你的教學做多一次,但得不到結搜尋結果....... =(
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5802 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 03:41 · PVG 11:41 · LAX 20:41 · JFK 23:41
    ♥ Do have faith in what you're doing.