Skip to content

Commit acaee23

Browse files
committed
added docs for mixins / inheritance
1 parent 3d2351d commit acaee23

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/src/piccolo/schema/advanced.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,24 @@ for example with ``table_finder`` (see :ref:`TableFinder`).
6262
6363
class Band(Table, tags=["music"]):
6464
name = Varchar(length=100)
65+
66+
-------------------------------------------------------------------------------
67+
68+
Mixins
69+
------
70+
71+
If you're frequently defining the same columns over and over again, you can
72+
use mixins to reduce the amount of repetition.
73+
74+
.. code-block:: python
75+
76+
from piccolo.columns import Varchar, Boolean
77+
from piccolo.table import Table
78+
79+
80+
class FavouriteMixin:
81+
favourite = Boolean(default=False)
82+
83+
84+
class Manager(FavouriteMixin, Table):
85+
name = Varchar()

0 commit comments

Comments
 (0)