Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating models docs

  • Loading branch information...
commit 269b5662e4a43d08b94bfd412c136a92d9cf17ea 1 parent 0d67c0a
@coleifer authored
Showing with 21 additions and 0 deletions.
  1. +21 −0 docs/peewee/models.rst
View
21 docs/peewee/models.rst
@@ -186,10 +186,31 @@ There are several options you can specify as ``Meta`` attributes:
* database: specifies a :py:class:`Database` instance to use with this model
* db_table: the name of the database table this model maps to
+* indexes: a list of fields to index
* ordering: a sequence of columns to use as the default ordering for this model
* pk_sequence: name of sequence to create for the primary key (peewee will autogenerate one
if not provided and the backend supports sequences).
+Specifying indexes:
+
+.. code-block:: python
+
+ class Transaction(Model):
+ from_acct = CharField()
+ to_acct = CharField()
+ amount = DecimalField()
+ date = DateTimeField()
+
+ class Meta:
+ indexes = (
+ # create a unique on from/to/date
+ (('from_acct', 'to_acct', 'date'), True),
+
+ # create a non-unique on from/to
+ (('from_acct', 'to_acct'), False),
+ )
+
+
Example of ordering:
.. code-block:: python
Please sign in to comment.
Something went wrong with that request. Please try again.