谢谢 Garth。我已经看到 Django 搜索想要成为正式的 Django 搜索,但是我犹豫要不要使用它,因为我找不到任何文档!幸运的是,这里有一个我从未见过的 颠覆中的自述文件,它让 API 看起来非常酷:
# set up the model
class Event(models.Model):
title = models.CharField(max_length=255)
date = models.DateField()
is_outdoors = models.BooleanField()
index = djangosearch.ModelIndex(text=['title'],
additional=['date', 'is_outdoors'])
# run a search
results = Event.index.search("django conference")
Obviously it lacks the speed, scalability and features of the real projects like Haystack, but this one is easier to set up, and I don't really need anything else than keyword AND-search.