Skip to content
This repository
Browse code

Updating models docs

  • Loading branch information...
commit 269b5662e4a43d08b94bfd412c136a92d9cf17ea 1 parent 0d67c0a
Charles Leifer authored August 13, 2012

Showing 1 changed file with 21 additions and 0 deletions. Show diff stats Hide diff stats

  1. 21  docs/peewee/models.rst
21  docs/peewee/models.rst
Source Rendered
@@ -186,10 +186,31 @@ There are several options you can specify as ``Meta`` attributes:
186 186
 
187 187
 * database: specifies a :py:class:`Database` instance to use with this model
188 188
 * db_table: the name of the database table this model maps to
  189
+* indexes: a list of fields to index
189 190
 * ordering: a sequence of columns to use as the default ordering for this model
190 191
 * pk_sequence: name of sequence to create for the primary key (peewee will autogenerate one
191 192
     if not provided and the backend supports sequences).
192 193
 
  194
+Specifying indexes:
  195
+
  196
+.. code-block:: python
  197
+
  198
+    class Transaction(Model):
  199
+        from_acct = CharField()
  200
+        to_acct = CharField()
  201
+        amount = DecimalField()
  202
+        date = DateTimeField()
  203
+
  204
+        class Meta:
  205
+            indexes = (
  206
+                # create a unique on from/to/date
  207
+                (('from_acct', 'to_acct', 'date'), True),
  208
+
  209
+                # create a non-unique on from/to
  210
+                (('from_acct', 'to_acct'), False),
  211
+            )
  212
+
  213
+
193 214
 Example of ordering:
194 215
 
195 216
 .. code-block:: python

0 notes on commit 269b566

Please sign in to comment.
Something went wrong with that request. Please try again.