D
D
difficultnicknameforcommu2017-08-20 16:01:05
Django
difficultnicknameforcommu, 2017-08-20 16:01:05

Django haystack how to setup lookup for intermediate models with foreign key?

Hello. For one of my projects, I'm adding a search for django haystack c solr.
There was a question how to search through foreign key.

# Модель по которой осуществляется поиск
class ItemModel(models.Model):
    name = models.CharField(max_length=255)
    
    
# Категория
class CategoryModel(models.Model):
    name = models.CharField(max_length=255)
    
    
# Связь между item и категорией
class ItemToCategoryModel(models.Model):
    item = models.ForeignKey('ItemModel')
    category = models.ForeignKey('CategoryModel')

How to build an index to search item by category?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question