Manish Wagle
Manish Wagle

Reputation: 545

Bootstrap CSS not found while hosting in pythonanywhere

I am trying to make an admin panel that includes some database. I have used flask-admin to automatically generate admin panel. When I ran the server locally in my PC, the bootstrap swatch is loading and works fine. However, when I hosted it in pythonanywhere and ran, it shows that the CSS is not found as shown in the image.

I have not used any templates of my own for admin panel. I used the following code to automatically generate the template.

admin = Admin(app, name='Admin Panel', template_mode='bootstrap3')

Link for the error message.

Image

Upvotes: 1

Views: 525

Answers (1)

omars
omars

Reputation: 8694

Same happened to me, but it turned out I used an unsupported swatch, here is the code that worked

app.config['FLASK_ADMIN_SWATCH'] = 'flatly'

# Create admin with custom base template
admin = admin.Admin(app, name='XXX', template_mode='bootstrap4')

Note that the Bootswatch theme name is case-sensitive. If set the FLASK_ADMIN_SWATCH config is set properly, there is no need to add the flask-admin css and js files to the static folder of your project.

The available themes are on the repo.

Upvotes: 1

Related Questions