Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

How to add css files to Django-Dash-Plotly

Greetings, so I have already connected and loaded my dash into django. Everything works great!

I seem to be running into this layout issue when I want a fixed column = image

I’m trying to figure out where to create my assets folder within my django project to store the custom CSS file to fix the issue above as per this solution : Another User had the same issue and solved it

This is the solution:

.dash-spreadsheet .row {
  flex-wrap: nowrap;

I notice that in the same directory where I have my dash in django, there is a static>dash folder, so I made my assets folder in there but couldn’t get it to work. According to this Adding CSS & JS and Overriding the Page-Load Template | Dash for Python Documentation | Plotly , I should have an assets folder that Dash can read directly.

Here are my from django












    # Common components

    # django-plotly-dash components
    # static support if serving local assets

    # Other components, as needed

Could anyone direct me where in my directory I should add the custom css files to help solve my original issue?

Take a look at the documentation here on serving local assets.

Should I only add serve_locally = True in my

like so:

                'serve_locally' = True

I also see that some people put it inside their dash-django argument. Which one would you recommend?

sorry if its obvious but after reading that documentation I’m still not sure where to place my local CSS files.

EDIT: I’ve tested both ways to implement serve_locally, neither works as the application keeps loading and gets stuck on HTTP GET for all Dash components.

@andres1 I think the best way forward would be to work through the documentation. It is nowhere near perfect, but it should be enough for you to get your app(s) working as desired.

If (when?) the documentation isn’t clear then raise that in the project’s issue tracker on github - this way the documentation can be improved for everyone.

To add css link in django dash framework
use below code and its works

app = DjangoDash('ReportOpt',add_bootstrap_links=True)  
app.css.append_css({ "external_url" : "/static/assets/css/dashstyle.css" })
1 Like

thank you for this!!!