I'm working to modify a cookiecutter Flask app. I'm working locally on WIN7 and attempting to deploy to heroku. I'm currently trying to add a datepicker to a page. I've found https://eonasdan.github.io/bootstrap-datetimepicker/. The structure of myflaskapp:
I've set up bower to install the front end dependencies under the static root by using a .bowerrc file in the document root containing:
{ "directory" : "myflaskapp/static/bower_components" }
This cookiecutter uses flask-assets to manage the project assets. Following https://adambard.com/blog/fresh-flask-setup/ I've modified myflaskapp/assets.py file :
from flask_assets import Bundle, Environment
import os
css = Bundle(
"libs/bootstrap/dist/css/spacelab/bootstrap.css",
"bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css",
"css/style.css",
"css/home.css",
# "css/style.css",
filters="cssmin",
output="public/css/common.css"
)
js = Bundle(
"libs/jQuery/dist/jquery.js",
"libs/bootstrap/dist/js/bootstrap.js",
"bower_components/moment/moment.js",
"bower_components/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js",
"js/plugins.js",
filters='jsmin',
output="public/js/common.js"
)
assets = Environment()
assets.register("js_all", js)
assets.register("css_all", css)
myflaskapp/app.py initializes the assets:
from flask import Flask, render_template
from myflaskapp.assets import assets
"""
:param config_object: The configuration object to use.
"""
app = Flask(__name__)
app.config.from_object(config_object)
register_extensions(app)
register_blueprints(app)
register_errorhandlers(app)
return app
def register_extensions(app):
assets.init_app(app)
def register_blueprints(app):
app.register_blueprint(public.blueprint)
app.register_blueprint(user.blueprint)
In the myflaskapp/settings.py , during testing, I have set:
ASSETS_DEBUG = True # Don't bundle/minify static assets
Locally, there are no errors in the console. On heroku , I get an Internal server error. Logs:
←[33m2016-03-19T18:02:12.464159+00:00 app[web.1]:←[0m for org, cnt in self.resolve_contents(ctx):
←[33m2016-03-19T18:02:12.464161+00:00 app[web.1]:←[0m raise BundleError(e)
←[33m2016-03-19T18:02:12.464162+00:00 app[web.1]:←[0m BundleError: 'bower_components/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css' not found in load path:
['/app/myflaskapp/static']
←[33m2016-03-19T18:02:12.464150+00:00 app[web.1]:←[0m rv = template.render(context)
←[33m2016-03-19T18:02:12.464151+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib/python2.7/site-packages/jinja2/environment.py", line 969, in render
←[33m2016-03-19T18:02:12.464152+00:00 app[web.1]:←[0m File "/app/.heroku/python/lib/python2.7/site-packages/jinja2/environment.py", line 742, in handle_exception
←[33m2016-03-19T18:02:12.464154+00:00 app[web.1]:←[0m {% extends "layout.html" %}
←[33m2016-03-19T18:02:12.464157+00:00 app[web.1]:←[0m urls = bundle.urls()
←[33m2016-03-19T18:02:12.464153+00:00 app[web.1]:←[0m reraise(exc_type, exc_value, tb)
As you can see in the top screenshot it is there. How can I fix this?
Note: I've been looking at https://github.com/mitsuhiko/flask/issues/348, which may have a bearing on this.