diff --git a/django/db/backends/postgresql_psycopg2/creation.py b/django/db/backends/postgresql_psycopg2/creation.py
index 90304aa..88afd5f 100644
|
a
|
b
|
class DatabaseCreation(BaseDatabaseCreation):
|
| 42 | 42 | |
| 43 | 43 | def sql_indexes_for_field(self, model, f, style): |
| 44 | 44 | output = [] |
| 45 | | if f.db_index: |
| | 45 | if f.db_index or f.unique: |
| 46 | 46 | qn = self.connection.ops.quote_name |
| 47 | 47 | db_table = model._meta.db_table |
| 48 | 48 | tablespace = f.db_tablespace or model._meta.db_tablespace |
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index a2081e0..c6a23db 100644
|
a
|
b
|
field, a :exc:`django.db.IntegrityError` will be raised by the model's
|
| 272 | 272 | This option is valid on all field types except :class:`ManyToManyField` and |
| 273 | 273 | :class:`FileField`. |
| 274 | 274 | |
| | 275 | Note that when ``unique`` is ``True``, you don't need to specify |
| | 276 | :attr:`~Field.db_index`, because ``unique`` implies the creation of an index. |
| | 277 | |
| 275 | 278 | ``unique_for_date`` |
| 276 | 279 | ------------------- |
| 277 | 280 | |
diff --git a/tests/regressiontests/indexes/models.py b/tests/regressiontests/indexes/models.py
index 4ab74d2..e38eb00 100644
|
a
|
b
|
if connection.vendor == 'postgresql':
|
| 17 | 17 | class IndexedArticle(models.Model): |
| 18 | 18 | headline = models.CharField(max_length=100, db_index=True) |
| 19 | 19 | body = models.TextField(db_index=True) |
| 20 | | slug = models.CharField(max_length=40, unique=True, db_index=True) |
| | 20 | slug = models.CharField(max_length=40, unique=True) |