I know how to do this with raw PostgreSQL commands, but want to know if there is a way to do this with Django PostgreSQL search.
class Person(models.Model):
name = models.CharField(max_length=64)
description = models.CharField(max_length=256)
active = models.BooleanField(default=False)
search_vector = SearchVectorField(blank=True)
def update_search(person):
vector = SearchVector('name') + SearchVector('description')
if person.active:
vector = vector + SearchVector('alive')
person.search_vector = vector
django.core.exceptions.FieldError: Cannot resolve keyword 'alive' into field.
I tried making 'alive' a @property method, but it looks like it only wants a db field for search.
Is there a way to do this in pure Django ORM or should I go the raw SQL route?