pip: dependency on javascript library

痴心易碎 提交于 2019-12-04 19:16:07
dnozay

As pointed out by @guettli you can use fanstatic packages.

E.g. requirements.txt

django
js.jquery
js.bootstrap
js.underscore
# ...

without django-fanstatic:

Then in your settings.py you can have:

import js
STATICFILES_DIRS = (
    ('js', js.__path__[0]),
)

And this is what I have in my base template:

<script src="{{ STATIC_URL }}js/jquery/resources/jquery.min.js"></script>
<script src="{{ STATIC_URL }}js/underscore/resources/underscore-min.js"></script>
<script src="{{ STATIC_URL }}js/bootstrap/resources/js/bootstrap.min.js"></script>

with django-fanstatic:

django-fanstatic provides a middleware to change the WSGI response. Some more info in this blog post.

pip install only python packages, so if you want to install a Javascript library, you should create a package that contains only the javascript library (declared as additional files).

Not sure if this is really mighty to do this.

Fanstatic already creates a lot of javascript packages (jquery, bootstrap, ...)

You can use the packages without using fanstatic ...

http://www.fanstatic.org/en/latest/libraries.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!