Skip to main content

The Django application that allows install and serve assets via Node.js package manager infrastructure.

Project description

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.


  • 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


$ pip install django-node-assets


Add ‘django_node_assets’ to your INSTALLED_APPS:


Add NodeModulesFinder to STATICFILES_FINDERS:


Specify absolute path to the package.json file:

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


A package.json must have the “dependencies” section and look like:

    "dependencies": {
        "jquery": "^3.2.1",
        "bootstrap": "^3.3.5",

Details here:

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

NODE_MODULES_ROOT = '/var/assets/node_modules'


A base dir must be called node_modules.

Specify path to the node package manager executable (optional)



The node package manager must be already installed in your system.


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

$ python 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>

Project details

Download files

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

Files for django-node-assets, version 0.9.9
Filename, size File type Python version Upload date Hashes
Filename, size django_node_assets-0.9.9-py3-none-any.whl (6.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size django-node-assets-0.9.9.tar.gz (4.5 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page