简体   繁体   English

Dash 引导组件未显示

[英]Dash bootstrap components not showing

I wanted to have progress bar in my Django project but it is not showing on page.我想在我的 Django 项目中有进度条,但它没有显示在页面上。 I have installed django-dash and dash-bootstrap-components.我已经安装了 django-dash 和 dash-bootstrap-components。 Code:代码:

import dash_html_components as html
import dash_bootstrap_components as dbc
from django_plotly_dash import DjangoDash

app = DjangoDash("Progress", add_bootstrap_links=True)
app.layout = html.Div(dbc.Progress(value=100))

and template和模板

{% load plotly_dash %}
<div class="{% plotly_class name="Progress" %}">
    {% plotly_app_bootstrap name="Progress" %}
</div>

I had a hard time figuring out why dash-bootstrap-components are not loaded on my Django dash app.我很难弄清楚为什么我的 Django dash 应用程序上没有加载 dash-bootstrap-components。 I figured out the problem using simple steps available at:我使用以下简单步骤解决了问题:

https://django-plotly-dash.readthedocs.io/en/latest/bootstrap.html#using-bootstrap https://django-plotly-dash.readthedocs.io/en/latest/bootstrap.html#using-bootstrap

This can be tricky to set up - you have to follow all of the installation steps.这可能很难设置 - 您必须遵循所有安装步骤。 There is a summary in the project documentation:项目文档中有一个总结

  • add the various settings from the configuration section of the project documentation, particularly the STATICFILES_FINDERS , PLOTLY_COMPONENTS and MIDDLEWARE ones.从项目文档的配置部分添加各种设置,特别是STATICFILES_FINDERSPLOTLY_COMPONENTSMIDDLEWARE
  • install django-bootstrap 4 with pip install django-bootstrap4 and add bootstrap4 to INSTALLED_APPS in the project's settings.py file使用pip install django-bootstrap4并将bootstrap4添加到项目的settings.py文件中的INSTALLED_APPS
  • make sure that the settings for serving static files are set correctly, particularly STATIC_ROOT , as described in the Django documentation确保正确设置为 static 文件提供服务的设置,尤其是STATIC_ROOT ,如 Django 文档中所述
  • use the prepare_demo script or perform the equivalent steps, particularly the migrate and collectstatic steps使用prepare_demo脚本或执行等效步骤,尤其是migratecollectstatic步骤

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM