我使用django-machina作为论坛应用程序,并且在框中集成了django-haystack,这很棒,但是我还不需要设置Sorl或Whoosh,客户端要求使用SQLite作为开始。但是,当我尝试以搜索形式搜索任何内容时,会收到这样的SQL查询:
SELECT forum_conversation_post.id, forum_conversation_post.created, forum_conversation_post.updated, forum_conversation_post.topic_id, forum_conversation_post.poster_id,
forum_conversation_post.poster_ip, forum_conversation_post.anonymous_key, forum_conversation_post.subject, forum_conversation_post.content, forum_conversation_post.username, forum_conversation_post.approved, forum_conversation_post.enable_signature, forum_conversation_post.update_reason, forum_conversation_post.updated_by_id, forum_conversation_post.updates_count, forum_conversation_post._content_rendered FROM forum_conversation_post WHERE (forum_conversation_post.anonymous_key LIKE '%[1]>%' ESCAPE '\' OR forum_conversation_post.subject LIKE '%[1]>%' ESCAPE '\' OR forum_conversation_post.content LIKE '%[1]>%' ESCAPE '\' OR forum_conversation_post.username LIKE '%[1]>%' ESCAPE '\' OR forum_conversation_post.update_reason LIKE '%[1]>%' ESCAPE '\' OR forum_conversation_post._content_rendered LIKE '%[1]>%' ESCAPE '\') ORDER BY forum_conversation_post.created ASC
简而言之,它只是将任何搜索短语在SQL级别更改为“ [1]>”字符串。
我花了很多时间来找出问题所在,但不明白为什么会发生以及如何解决问题。