{"id":7174,"library":"django-pipeline","title":"Django Pipeline","description":"Django-pipeline is an active asset packaging library for Django (current version 4.1.0) that streamlines frontend development by providing CSS and JavaScript concatenation, compression, built-in JavaScript template support, and optional data-URI embedding. It integrates with Django's staticfiles system, typically releasing new versions as needed to maintain compatibility with major Django updates.","status":"active","version":"4.1.0","language":"en","source_language":"en","source_url":"https://github.com/jazzband/django-pipeline","tags":["Django","assets","CSS","JavaScript","compression","staticfiles","frontend"],"install":[{"cmd":"pip install django-pipeline","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core framework integration.","package":"Django","optional":false},{"reason":"External JavaScript/CSS compilers (e.g., Yuglify, UglifyJS, Less, Sass) often require Node.js and NPM for installation.","package":"Node.js (for compilers)","optional":true}],"imports":[{"note":"Ensure 'pipeline' is listed in your project's INSTALLED_APPS setting in settings.py.","wrong":"apps.add('pipeline')","symbol":"pipeline","correct":"INSTALLED_APPS = ['pipeline']"},{"note":"Required to enable Pipeline's static file handling and manifest generation.","symbol":"PipelineManifestStorage","correct":"STATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'"},{"note":"Adds Pipeline's finder to locate static assets.","symbol":"PipelineFinder","correct":"STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'pipeline.finders.PipelineFinder',)"},{"note":"The template library changed from 'compressed' to 'pipeline' in newer versions.","wrong":"{% load compressed %}","symbol":"pipeline template tags","correct":"{% load pipeline %}"}],"quickstart":{"code":"import os\nfrom pathlib import Path\n\nBASE_DIR = Path(__file__).resolve().parent.parent\n\n# settings.py snippets\nINSTALLED_APPS = [\n    # ... other apps\n    'django.contrib.staticfiles',\n    'pipeline',\n]\n\nSTATIC_URL = '/static/'\nSTATIC_ROOT = BASE_DIR / 'staticfiles'\nSTATICFILES_DIRS = [\n    BASE_DIR / 'static',\n]\n\nSTATICFILES_STORAGE = 'pipeline.storage.PipelineManifestStorage'\nSTATICFILES_FINDERS = (\n    'django.contrib.staticfiles.finders.FileSystemFinder',\n    'django.contrib.staticfiles.finders.AppDirectoriesFinder',\n    'pipeline.finders.PipelineFinder',\n)\n\nPIPELINE = {\n    'STYLESHEETS': {\n        'main_css': {\n            'source_filenames': (\n                'css/normalize.css',\n                'css/base.css',\n            ),\n            'output_filename': 'css/packed_css.css',\n            'extra_context': {\n                'media': 'screen,projection',\n            },\n        },\n    },\n    'JAVASCRIPT': {\n        'main_js': {\n            'source_filenames': (\n                'js/jquery.js',\n                'js/app.js',\n            ),\n            'output_filename': 'js/packed_js.js',\n        }\n    }\n}\n\n# Example of manually specifying a compressor binary if needed\n# PIPELINE.update({\n#     'YUGLIFY_BINARY': os.path.join(BASE_DIR, 'node_modules/.bin/yuglify'),\n# })\n\n# -----------------------------------------------------\n# templates/base.html (or similar)\n# Add at the top of the template:\n# {% load pipeline %}\n\n# In <head> for CSS:\n# {% stylesheet 'main_css' %}\n\n# Before </body> for JS:\n# {% javascript 'main_js' %}\n\n# After configuring settings.py and templates, run:\n# python manage.py collectstatic\n","lang":"python","description":"This quickstart demonstrates basic configuration in `settings.py` for CSS and JavaScript asset groups. It includes setting `INSTALLED_APPS`, `STATICFILES_STORAGE`, `STATICFILES_FINDERS`, and the `PIPELINE` dictionary. In your templates, load the `pipeline` tags and use `{% stylesheet 'group_name' %}` and `{% javascript 'group_name' %}`. Remember to run `python manage.py collectstatic` after configuration for production."},"warnings":[{"fix":"To see compressed output, ensure `DEBUG = False` in your `settings.py` and run `python manage.py collectstatic`. For debugging, keep `DEBUG = True` to load individual files.","message":"Pipeline's asset compression and bundling features are only active when Django's `DEBUG` setting is `False`. When `DEBUG` is `True`, Pipeline serves individual source files for easier debugging, which can be confusing if you expect bundled output in development.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Install required compilers/compressors via your system's package manager or Node.js's npm (e.g., `npm install -g yuglify`). Then, configure the absolute path to the binary in your `PIPELINE` settings, for example: `PIPELINE.update({'YUGLIFY_BINARY': '/usr/local/bin/yuglify'})`.","message":"`django-pipeline` often requires external binary compilers/compressors (e.g., Yuglify, UglifyJS, Less, Sass). These tools must be installed manually (e.g., via Node.js/NPM) and their paths correctly configured in your `PIPELINE` settings. Failure to do so will result in 'command not found' errors during `collectstatic` or when serving assets.","severity":"breaking","affected_versions":"All versions"},{"fix":"Update your `settings.py` to use `STORAGES` instead of `STATICFILES_STORAGE`. Example: `STORAGES = {'staticfiles': {'BACKEND': 'pipeline.storage.PipelineManifestStorage'}}`. Remove the old `STATICFILES_STORAGE` setting.","message":"For Django versions 4.2 and higher, the `STATICFILES_STORAGE` setting is superseded by the `STORAGES` setting. While `STATICFILES_STORAGE` might still work for static files in some configurations, it is recommended to update to the `STORAGES` dictionary format for full compatibility and future-proofing.","severity":"deprecated","affected_versions":"Django 4.2+"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Add `'pipeline'` to your `INSTALLED_APPS` list in `settings.py`: `INSTALLED_APPS = [... 'pipeline',]`","cause":"The 'pipeline' app is not included in your Django project's `INSTALLED_APPS` setting.","error":"ModuleNotFoundError: No module named 'pipeline'"},{"fix":"Ensure `DEBUG = False` for production behavior. Run `python manage.py collectstatic` after any changes to `PIPELINE` settings or static files. Verify that `STATICFILES_STORAGE` is set to `'pipeline.storage.PipelineManifestStorage'` (or correctly configured within `STORAGES` for Django 4.2+).","cause":"This typically occurs because `DEBUG = True` (disabling compression), `python manage.py collectstatic` was not run, or `STATICFILES_STORAGE` is incorrectly configured.","error":"No static file generated by django-pipeline for group 'my_group' OR 'Hashed filenames not being updated'"},{"fix":"Install the missing binary (e.g., `npm install -g yuglify` or `sudo apt-get install yuglify`). If the binary is not in your system's PATH, explicitly set its absolute path in your `PIPELINE` settings, e.g., `PIPELINE['YUGLIFY_BINARY'] = '/usr/local/bin/yuglify'`.","cause":"An external compressor or compiler binary (like `yuglify`, `uglifyjs`, `lessc`, `sass`) is specified in your `PIPELINE` settings but is not installed on your system or its path is not correctly configured.","error":"django.core.exceptions.ImproperlyConfigured: 'yuglify' could not be found. Make sure it's installed and available in your PATH."}]}