1

Dependencies to other python libraries can be declared by pip's requirements.txt.

But is it possible to declare a dependency to a pure js library?

The library is available from github. The files should be downloaded an made available for django static file handling.

Background: setting up new development environments of a custom django application should be easy.

How do you handle this in your development environment?

guettli
  • 25,042
  • 81
  • 346
  • 663
  • I would write a small management code which checks the existence of the requirements then download them if they don't exists, and put them into either separate python file or `__init__.py` of project top folder or maybe somewhere in `manage.py` – Umur Kontacı Aug 07 '12 at 08:59

3 Answers3

1

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.

Community
  • 1
  • 1
dnozay
  • 23,846
  • 6
  • 82
  • 104
0

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.

0

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

guettli
  • 25,042
  • 81
  • 346
  • 663