Skip to main content

Django-node-assets

https://travis-ci.org/whitespy/django-node-assets.svg https://badge.fury.io/py/django-node-assets.svg https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat&labelColor=ef8336

The Django application that allows to install and to serve static assets via Node.js package manager infrastructure. The application exposes management command to install dependencies from your package.json and several static files finders to find files from installed node packages and exclude metadata of node packages and unwanted files when static files will be collected via Django`s collectstatic management command execution.

Features

  • Avoiding vendoring static assets in your repository like jQuery plugins, Bootstrap toolkit, etc

  • Avoiding mess in STATIC_ROOT through exclusion node packages` metatadata and unwanted files

  • Installing dependencies by Django`s management command

Installation

$ pip install django-node-assets

Configuration

Add ‘django_node_assets’ to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    'django_node_assets',
]

Add NodeModulesFinder to STATICFILES_FINDERS:

STATICFILES_FINDERS = [
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'django_node_assets.finders.NodeModulesFinder',
]

Specify absolute path to the package.json file:

NODE_PACKAGE_JSON = '/var/assets/package.json'

Specify the absolute path to a directory where the nmpinstall management command will install assets:

NODE_MODULES_ROOT = '/var/assets/node_modules'

Specify path to the node package manager executable (optional)

NODE_PACKAGE_MANAGER_EXECUTABLE = '/usr/local/bin/npm'

Usage

Call the nmpinstall management command to install dependencies specified in the package.json

$ python manage.py npminstall

Use Django`s static template tag to link installed assets

{% load static %}

<link rel="stylesheet" type="text/css" href="{% static 'bootstrap/dist/css/bootstrap.min.css' %}">
<!-- Some amazing markup -->
<script src="{% static 'jquery/dist/jquery.min.js' }"><script>
<script src="{% static 'bootstrap/dist/js/bootstrap.js' }"><script>

Metadata

Release files for django-node-assets 0.9.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-node-assets 0.9.10
File Size Uploaded Provenance Actions
django-node-assets-0.9.10.tar.gz 5.2 kB Without provenance Details for django-node-assets-0.9.10.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-node-assets 0.9.10
File Interpreter ABI Platform Actions
django_node_assets-0.9.10-py3-none-any.whl Python 3 none any Details for django_node_assets-0.9.10-py3-none-any.whl

Total release size: 11.2 kB

Release files / django-node-assets-0.9.10.tar.gz

Download URL django-node-assets-0.9.10.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
89118fb7eb61453ba09282df5f25e723c2dbd46de601e50eb58951d0011ed407
BLAKE2b-256 checksum
How to use checksums
14ba612a5a93bf750097454f376e610816a989c7832b1ae3f3f6dee6d6e3e213
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10

Release files / django_node_assets-0.9.10-py3-none-any.whl

Download URL django_node_assets-0.9.10-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33cb1cf7b9007252204b08a229f78973d4a65f160cd52a32247895133019ba29
BLAKE2b-256 checksum
How to use checksums
8997131f2045bb5958188ee2ef7c5bbe35092caa51f1c62cc5aa69ebe79eb338
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.10

Security for django-node-assets 0.9.10

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page