-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from piccolo-orm/choices
Choices
- Loading branch information
Showing
27 changed files
with
465 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import annotations | ||
from dataclasses import dataclass | ||
import typing as t | ||
|
||
|
||
@dataclass | ||
class Choice: | ||
""" | ||
When defining enums for ``Column`` choices, they can either be defined | ||
like: | ||
.. code-block:: python | ||
class Title(Enum): | ||
mr = 1 | ||
mrs = 2 | ||
If using Piccolo Admin, the values shown will be ``Mr`` and ``Mrs``. If you | ||
want more control, you can use ``Choice`` for the value instead. | ||
.. code-block:: python | ||
class Title(Enum): | ||
mr = Choice(value=1, display_name="Mr.") | ||
mrs = Choice(value=1, display_name="Mrs.") | ||
Now the values shown will be ``Mr.`` and ``Mrs.``. | ||
""" | ||
|
||
value: t.Any | ||
display_name: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.