Skip to main content

Integrate django with yarnpkg

Project description

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+

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-yarnpkg-6.0.2.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

django_yarnpkg-6.0.2-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

Details for the file django-yarnpkg-6.0.2.tar.gz.

File metadata

  • Download URL: django-yarnpkg-6.0.2.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for django-yarnpkg-6.0.2.tar.gz
Algorithm Hash digest
SHA256 6906b3555430c4e397413a348ae51657e29b4afa81ee6f20c22626bb27f4f972
MD5 d0abff78d298ea9eeadd4b1a9065028d
BLAKE2b-256 636c46c3af9d9f3f4a257397517b1cd14194e72395911133d66e6478536cf3f0

See more details on using hashes here.

Provenance

File details

Details for the file django_yarnpkg-6.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_yarnpkg-6.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2507ff439de47f3a54549b39976282850b4d5171f025151dbe4f8479becd94be
MD5 b4c6706f1a9f34762ce057f525347747
BLAKE2b-256 402722b2ce2123d519feee4cfa075df3e71f4c61d73c8194a74638e215648823

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page