Skip to main content

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

Project description

https://travis-ci.org/whitespy/django-node-assets.svg https://badge.fury.io/py/django-node-assets.svg

The Django application that allows install and 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_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>

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-node-assets-0.9.5.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

django_node_assets-0.9.5-py2-none-any.whl (4.5 kB view details)

Uploaded Python 2

File details

Details for the file django-node-assets-0.9.5.tar.gz.

File metadata

  • Download URL: django-node-assets-0.9.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/2.7

File hashes

Hashes for django-node-assets-0.9.5.tar.gz
Algorithm Hash digest
SHA256 a1035aa4639e34af51fcfadbf8f4cdfb9ec2ac397ef8784e8c58cd75f1680833
MD5 9b83a90ed483d3f2e88e1713b4132109
BLAKE2b-256 dd9eb9d080591bd4b4dc4882ae85808422e116814147a682e8e91cd84b80bf29

See more details on using hashes here.

File details

Details for the file django_node_assets-0.9.5-py2-none-any.whl.

File metadata

File hashes

Hashes for django_node_assets-0.9.5-py2-none-any.whl
Algorithm Hash digest
SHA256 11f1a2fab1082b7e7be7d2649dea0674b339139a556e1ff1ea89168a07e334b6
MD5 5c9225288abdf023f8aeb0efbe825df7
BLAKE2b-256 5ecc7f722561874736aa564ca1521240d08ef15b50d8a60fb02abffb1ac7aa99

See more details on using hashes here.

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