我正在使用haystack(2.1.1)并在我的django(1.7)网站上嗖的一声.我很高兴因为它有效但不完全.该应用程序显示正确的搜索,但当我点击结果时,它不会转到产品页面.看起来我没有配置使{{result.object.get_absolute_url}}无法正常工作的东西.我希望你们中的任何人都可以帮助我(作为参考,我把所有代码都放在一边)
这是我的应用型号(产品/型号)
from django.db import models
class Products(models.Model):
name = models.CharField(max_length=120)
description = models.TextField()
image1 = models.ImageField(upload_to='product_images', blank=True, null=True)
price = models.FloatField(default=0.00)
slug = models.CharField(max_length=50, blank=False, null=True)
pub_date = models.DateTimeField()
def __unicode__(self):
return str(self.name)
class Meta:
ordering =['-id']
verbose_name = ('Product')
verbose_name_plural = ('Products')
Run Code Online (Sandbox Code Playgroud)
这是我的search_indexes.py,我把它放在我的应用程序的同一个文件夹中(products/search_indexes.py)
import datetime
from haystack import indexes
from products.models import Products
class ProductsIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
name = indexes.CharField(model_attr='name')
description = indexes.CharField(model_attr='description')
pub_date = indexes.DateTimeField(model_attr='pub_date')
def get_model(self):
return Products
def index_queryset(self, using=None):
return self.get_model().objects.filter(pub_date__lte=datetime.datetime.now()) …Run Code Online (Sandbox Code Playgroud) 我在Mac(小牛队)中使用Django-Oscar.并且一切看起来都很好,但它没有显示任何正确上传的图像.在一开始我认为这是一个解决问题,但它将图片保存在正确的文件夹中.所以这不是问题.然后我试图安装libjpeg,因为它是在安装教程中推荐的.
我卸下了枕头
pip uninstall pillow
Run Code Online (Sandbox Code Playgroud)
然后我用这个命令,我在网上找到安装libjpeg
brew install libjpeg
Run Code Online (Sandbox Code Playgroud)
然后我再次安装枕头,然后一切都是一样的.它仍然没有显示任何图像,终端显示已经安装了jpeg-8d
有人可以帮助我吗 谢谢