2

looking to specify the themed css for bootstrap. can't get bootstrap_find_resource to look to my locally placed css files. Seems to continue to pull from the /site-packages/flask_bootstrap location.

the current default for bootstrap css is pointing here

<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">

and this is the macro generating the url

<link href="{{bootstrap_find_resource('css/bootstrap.css', cdn='bootstrap')}}" rel="stylesheet">

bootstrap_find_resource code pointed me to the BOOTSTRAP_SERVE_LOCAL config. setting it to true gave me a local endpoint. which created the local endpoint

<link href="/static/bootstrap/css/bootstrap.min.css?bootstrap=3.3.5.7" rel="stylesheet">

so I placed the bootstrap css in this local app static folder /static/bootstrap/css/. and i verified that flask's app.static_folder is actually mapped to where I put the new files. still pulling from site packages and ignores my local static files.

Paul Rooney
  • 20,879
  • 9
  • 40
  • 61
user2647293
  • 25
  • 1
  • 7

1 Answers1

2

bootstrap_find_resource is for loading static files distributed with Flask-Bootstrap. For your own files, use url_for.

{% block styles %}
    {{ super() }}
    <link rel="stylesheet" href="{{ url_for('static', filename='locally/placed.css') }}">
{% endblock %}
dirn
  • 19,454
  • 5
  • 69
  • 74
  • url_for would work and is the answer. do you know how to go about sub classing the base.html template to provide this override? – user2647293 Jan 28 '16 at 06:35
  • You should use the `styles` block. I'll update the answer. – dirn Jan 28 '16 at 12:42
  • Hi @dirn I know it has been sometime, but does that mean that the style block will have to be included in the base.html if I were to extend from it? Or I can put it at the top of any of my html files referring to the css? Thanks! – BernardL Aug 16 '18 at 04:37