Bootstrap5模板包,用于django-crispy-forms
项目描述
crispy-bootstrap5
Bootstrap5模板包,用于django-crispy-forms
安装
使用pip
安装此插件
$ pip install crispy-bootstrap5
用法
您需要更新项目的设置文件,将crispy_forms
和crispy_bootstrap5
添加到项目的INSTALLED_APPS
中。同时将bootstrap5
设置为允许的模板包,并作为项目的默认模板包
INSTALLED_APPS = (
...
"crispy_forms",
"crispy_bootstrap5",
...
)
CRISPY_ALLOWED_TEMPLATE_PACKS = "bootstrap5"
CRISPY_TEMPLATE_PACK = "bootstrap5"
有什么新功能?
Bootstrap 5引入了浮动标签。此模板包包含一个布局对象来使用此输入类型
from crispy_bootstrap5.bootstrap5 import FloatingField
# then in your Layout
... Layout(
FloatingField("first_name"),
)
手风琴也增加了新功能,例如手风琴填充和始终打开。有一个新的布局对象来使用它们
from crispy_bootstrap5.bootstrap5 import BS5Accordion
# then in your Layout
# if not informed, flush and always_open default to False
... Layout(
BS5Accordion(
AccordionGroup("group name", "form_field_1", "form_field_2"),
AccordionGroup("another group name", "form_field"),
flush=True,
always_open=True
)
)
添加了对开关的支持。开关是作为切换开关渲染的自定义复选框。这些字段的部件应为CheckboxInput。
from crispy_bootstrap5.bootstrap5 import Switch
... Layout(Switch("is_company"))
开发
要为此库做出贡献,首先检出代码。然后创建一个新的虚拟环境
cd crispy-bootstrap5
python -mvenv venv
source venv/bin/activate
或如果您正在使用pipenv
pipenv shell
现在安装依赖项和测试
pip install -e '.[test]'
要运行测试
pytest
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源代码分发
crispy-bootstrap5-2024.2.tar.gz (23.4 kB 查看哈希值)
构建分发
关闭
crispy-bootstrap5-2024.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 7d1fa40c6faf472e30e85c72551a3d2c9eedbf0abfff920683315e4e6f670f2b |
|
MD5 | cdc959eb28cde53c5594b5d225a369fc |
|
BLAKE2b-256 | 7545af5c7a13742650b1187a1a6db5197577b57f2b1ca3a042c3b386ddfbebfc |
关闭
crispy_bootstrap5-2024.2-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 3867e320920a6ef156e94f9e0f06a80344c453e1b3bd96cd9dc0522ae9e9afb8 |
|
MD5 | 92fc180cf23546d83bcf5c62e9167c63 |
|
BLAKE2b-256 | 1311a1c22b4c803125901af7d2fa683f4c6eb14d511644da5fc0b45a0cb44cae |