Skip to content

Commit c29d873

Browse files
docs(examples): add form_choices usage to peewee_simple example
1 parent 5faec6f commit c29d873

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

examples/peewee_simple/main.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Post(BaseModel):
4242
title = CharField(max_length=120)
4343
text = peewee.TextField(null=False)
4444
date = peewee.DateTimeField()
45+
status = CharField(max_length=20, default="draft")
4546

4647
user = peewee.ForeignKeyField(User)
4748

@@ -70,6 +71,15 @@ class PostAdmin(ModelView):
7071

7172
form_ajax_refs = {"user": {"fields": (User.username, "email")}}
7273

74+
form_choices = {
75+
"status": [
76+
("draft", "Draft"),
77+
("review", "In Review"),
78+
("published", "Published"),
79+
("archived", "Archived"),
80+
]
81+
}
82+
7383

7484
class Book(BaseModel):
7585
isbn = CharField(max_length=13, primary_key=True)
@@ -131,7 +141,9 @@ def index():
131141

132142
# Create tables first
133143
with db:
134-
db.drop_tables([BookCategory, Post, UserInfo, Book, Category, User], safe=True)
144+
db.drop_tables(
145+
[BookCategory, Post, UserInfo, Book, Category, User], safe=True
146+
)
135147
db.create_tables(
136148
[User, UserInfo, Post, Book, Category, BookCategory], safe=True
137149
)

0 commit comments

Comments
 (0)