Skip to content

Filtering on index.RelatedFieldsΒ #12

@kaedroho

Description

@kaedroho

For Example, say we have the following models:

class Author(models.Model):
    name = models.CharField()
    birth_date = models.DateField()
    ...


class Book(index.Indexed, models.Model):
    title = models.CharField()
    author = models.ForeignKey(Author)
    ...

    search_fields = [
        index.SearchField("title"),
        index.RelatedFields("author", [
            index.FilterField("birth_date")
        ]),
    ]

The following query won't work, because author__birth_date can't be used:

Book.objects.filter(author__birth_date__lt=date(1, 1, 1950)).search("A search query")

This is currently unimplemented because of the way Django stores related filter lookups on QuerySets is quite difficult to reverse.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

Status

πŸ— In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions