diff options
| author | Marc Tamlyn <marc.tamlyn@gmail.com> | 2015-05-31 22:45:03 +0100 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2016-04-22 10:44:37 +0100 |
| commit | 2d877da85526bad0dad7fd6b1d56b1f924c0116a (patch) | |
| tree | cfb530183be389e928351aa25f3fb5a03f59a1af /tests/postgres_tests/models.py | |
| parent | f4c2b8e04a297f627a8e722d78eda6cbf5cc8a6e (diff) | |
Refs #3254 -- Added full text search to contrib.postgres.
Adds a reasonably feature complete implementation of full text search
using the built in PostgreSQL engine. It uses public APIs from
Expression and Lookup.
With thanks to Tim Graham, Simon Charettes, Josh Smeaton, Mikey Ariel
and many others for their advice and review. Particular thanks also go
to the supporters of the contrib.postgres kickstarter.
Diffstat (limited to 'tests/postgres_tests/models.py')
| -rw-r--r-- | tests/postgres_tests/models.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py index 24addea358..d94eb90d4a 100644 --- a/tests/postgres_tests/models.py +++ b/tests/postgres_tests/models.py @@ -3,6 +3,7 @@ from django.db import connection, models from .fields import ( ArrayField, BigIntegerRangeField, DateRangeField, DateTimeRangeField, FloatRangeField, HStoreField, IntegerRangeField, JSONField, + SearchVectorField, ) @@ -78,6 +79,37 @@ class CharFieldModel(models.Model): class TextFieldModel(models.Model): field = models.TextField() + def __str__(self): + return self.field + + +# Scene/Character/Line models are used to test full text search. They're +# populated with content from Monty Python and the Holy Grail. +class Scene(models.Model): + scene = models.CharField(max_length=255) + setting = models.CharField(max_length=255) + + def __str__(self): + return self.scene + + +class Character(models.Model): + name = models.CharField(max_length=255) + + def __str__(self): + return self.name + + +class Line(PostgreSQLModel): + scene = models.ForeignKey('Scene', models.CASCADE) + character = models.ForeignKey('Character', models.CASCADE) + dialogue = models.TextField(blank=True, null=True) + dialogue_search_vector = SearchVectorField(blank=True, null=True) + dialogue_config = models.CharField(max_length=100, blank=True, null=True) + + def __str__(self): + return self.dialogue or '' + class RangesModel(PostgreSQLModel): ints = IntegerRangeField(blank=True, null=True) |
