5
0
Fork
You've already forked django-yarnpkg
0
Easy way to use yarnpkg with your Django project.
  • Python 97.6%
  • HTML 2.4%
Find a file
2026年04月28日 12:11:07 +02:00
django_yarnpkg Drop usage of distutils 2025年03月20日 00:18:26 +01:00
docs Fix URLs 2026年04月28日 12:11:07 +02:00
example Port from bower to yarn. 2019年12月07日 23:25:00 +01:00
.coveragerc Port from bower to yarn. 2019年12月07日 23:25:00 +01:00
.gitignore Add dist/ to gitignore. 2019年12月07日 23:26:00 +01:00
.gitlab-ci.yml Update python Docker tag to v3.9 2020年11月11日 15:47:39 +00:00
CHANGELOG.rst Drop usage of distutils 2025年03月20日 00:18:26 +01:00
LICENSE Fix URLs 2026年04月28日 12:11:07 +02:00
README.rst Fix URLs 2026年04月28日 12:11:07 +02:00
renovate.json Add renovate.json 2020年02月08日 13:02:15 +00:00
requirements_dev.txt Add coverage test 2013年09月01日 03:39:21 +04:00
runtests.py Port from bower to yarn. 2019年12月07日 23:25:00 +01:00
setup.py Fix URLs 2026年04月28日 12:11:07 +02:00

Django-yarnpkg

Easy way to use yarnpkg with your Django project.

This is a fork of django-bower <https://github.com/nvbn/django-bower> by Vladimir Iakovlev.

Read full documentation on read-the-docs.

Installation

Install django-yarnpkg package:

 pip install django-yarnpkg

Add django-bower to INSTALLED_APPS in your settings:

 'django_yarnpkg',

Add staticfinder to `STATICFILES_FINDERS`:

 'django_yarnpkg.finders.NodeModulesFinder',

Specify path to components root (you need to use an absolute path):

NODE_MODULES_ROOT = os.path.join(BASE_DIR, 'node_modules')

If you need, you can manually set the path to yarnpkg:

YARN_PATH = '/usr/bin/yarnpkg'

You can see an example settings file in example project.

Usage

Specify YARN_INSTALLED_APPS in settings, like:

YARN_INSTALLED_APPS = (
 'bootstrap@^4.4.1',
 'underscore@^1.6.1',
)

Download yarn packages with the management command:

 ./manage.py yarn install

Add scripts in the template, like:

{% load static %}
<script type="text/javascript" src='{% static 'jquery/dist/jquery.js' %}'></script>

In production you need to call yarnpkg install before `collectstatic`:

 ./manage.py yarn install
 ./manage.py collectstatic

If you need to pass arguments to yarnpkg, like --flat, use:

 ./manage.py yarn install -- --flat

You can call yarnpkg commands like info and update with:

 ./manage.py yarn info backbone
 ./manage.py yarn update

Python 3 support

django-yarnpkg supports python 3.3+