FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
fastapi-admin/examples/models.py at dev · sleepergithub/fastapi-admin · GitHub
sleepergithub
fastapi-admin
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
fastapi-admin
/
examples
/
models.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (31 loc) · 1.42 KB
Breadcrumbs
fastapi-admin
/
examples
/
models.py
Copy path
File metadata and controls
42 lines (31 loc) · 1.42 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import
datetime
from
tortoise
import
Model
,
fields
from
examples
.
enums
import
ProductType
,
Status
from
fastapi_admin
.
models
import
AbstractAdmin
class
Admin
(
AbstractAdmin
):
last_login
=
fields
.
DatetimeField
(
description
=
"Last Login"
,
default
=
datetime
.
datetime
.
now
)
email
=
fields
.
CharField
(
max_length
=
200
)
avatar
=
fields
.
CharField
(
max_length
=
200
,
default
=
""
)
intro
=
fields
.
TextField
(
default
=
""
)
created_at
=
fields
.
DatetimeField
(
auto_now_add
=
True
)
def
__str__
(
self
):
return
f"
{
self
.
pk
}
#
{
self
.
username
}
"
class
Category
(
Model
):
slug
=
fields
.
CharField
(
max_length
=
200
)
name
=
fields
.
CharField
(
max_length
=
200
)
created_at
=
fields
.
DatetimeField
(
auto_now_add
=
True
)
class
Product
(
Model
):
categories
=
fields
.
ManyToManyField
(
"models.Category"
)
name
=
fields
.
CharField
(
max_length
=
50
)
view_num
=
fields
.
IntField
(
description
=
"View Num"
)
sort
=
fields
.
IntField
()
is_reviewed
=
fields
.
BooleanField
(
description
=
"Is Reviewed"
)
type
=
fields
.
IntEnumField
(
ProductType
,
description
=
"Product Type"
)
image
=
fields
.
CharField
(
max_length
=
200
)
body
=
fields
.
TextField
()
created_at
=
fields
.
DatetimeField
(
auto_now_add
=
True
)
class
Config
(
Model
):
label
=
fields
.
CharField
(
max_length
=
200
)
key
=
fields
.
CharField
(
max_length
=
20
,
unique
=
True
,
description
=
"Unique key for config"
)
value
=
fields
.
JSONField
()
status
:
Status
=
fields
.
IntEnumField
(
Status
,
default
=
Status
.
on
)
Back
|
FazBrowse Home
|
New Git URL