
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
django-node-assets
Advanced tools
The Django application that allows to install and serve assets via Node.js package manager infrastructure.
################## Django-node-assets ##################
.. image:: https://badge.fury.io/py/django-node-assets.svg :target: https://badge.fury.io/py/django-node-assets
.. image:: https://img.shields.io/badge/linter-ruff-FF69B4 :target: https://github.com/astral-sh/ruff
.. image:: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml/badge.svg :target: https://github.com/whitespy/django-node-assets/actions/workflows/code_quality_check.yml
|
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.
.. code:: bash
$ pip install django-node-assets
Add 'django_node_assets' to your INSTALLED_APPS:
.. code:: python
INSTALLED_APPS = [
...
"django_node_assets",
]
Add NodeModulesFinder to STATICFILES_FINDERS:
.. code:: python
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:
.. code:: python
NODE_PACKAGE_JSON = "/var/assets/package.json"
.. note::
A package.json must have the "dependencies" section and look like:
.. code:: json
{
"dependencies": {
"jquery": "^3.2.1",
"bootstrap": "^3.3.5"
}
}
Details here: https://docs.npmjs.com/files/package.json#dependencies
Specify the absolute path to a directory where the npminstall management command will install assets:
.. code:: python
NODE_MODULES_ROOT = "/var/assets/node_modules"
.. note::
A base dir must be called **node_modules**.
Override path to the node package manager executable (optional)
.. code:: python
NODE_PACKAGE_MANAGER_EXECUTABLE = "/usr/local/bin/npm"
.. note::
The node package manager must be already installed in your system.
Override options of the node package manager install command (optional)
.. code:: python
NODE_PACKAGE_MANAGER_INSTALL_OPTIONS = ["--dry-run"]
Defaults to --no-package-lock, --production.
Call the npminstall management command to install dependencies specified in the package.json
.. code:: bash
$ python manage.py npminstall
Use Django`s static template tag to link installed assets
.. code:: html
{% 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>
FAQs
The Django application that allows to install and serve assets via Node.js package manager infrastructure.
We found that django-node-assets demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.