43👍
✅
Haven’t yet had a chance to migrate my old manual CREATE INDEX
codes to the new system introduced in 1.11
but my understanding is
from django.contrib.postgres.indexes import GinIndex
import django.contrib.postgres.search as pg_search
class EntryLine(models.Model):
speaker = models.CharField(max_length=512, db_index=True)
text = models.TextField()
sv = pg_search.SearchVectorField(null=True)
class Meta:
indexes = [GinIndex(fields=['sv'])]
Is what’s required. Raw SQL CREATE INDEX
statements need not be used any more.
👤e4c5
Source:stackexchange.com