django-require
raw JSON → 3.0.0 verified Fri May 01 auth: no python
A Django staticfiles post-processor for optimizing JavaScript with RequireJS. Version 3.0.0 is the latest; development appears to be in maintenance mode with sporadic releases.
pip install openedx-django-require Common errors
error ImportError: No module named 'require' ↓
cause The 'require' app is not installed or the package is not installed.
fix
Install with
pip install openedx-django-require and add 'require' to INSTALLED_APPS. error django.core.exceptions.ImproperlyConfigured: The REQUIREJS_BASE_URL setting is not set. ↓
cause Missing required setting REQUIREJS_BASE_URL.
fix
Add 'REQUIREJS_BASE_URL = 'js/lib'' (or your base path) to settings.
Warnings
breaking In version 2.x, the staticfiles storage was named 'require.storage.OptimizedCachedStaticFilesStorage'. This was removed in 3.0. Use 'require.storage.OptimizedStaticFilesStorage' instead. ↓
fix Change STATICFILES_STORAGE to 'require.storage.OptimizedStaticFilesStorage'.
deprecated The management command `compress_require` has been deprecated in favor of Django's native `collectstatic` with the optimized storage. ↓
fix Use `python manage.py collectstatic` instead of `python manage.py compress_require`.
gotcha The `REQUIREJS_BASE_URL` setting is relative to STATIC_URL. If STATIC_URL is not set correctly, the optimizer may fail to find files. ↓
fix Ensure STATIC_URL is properly configured in your Django settings.
Imports
- OPTIMIZER
from require.settings import OPTIMIZER - RequireJSException
from require.exceptions import RequireJSException
Quickstart
INSTALLED_APPS = [
...
'require',
]
STATICFILES_STORAGE = 'require.storage.OptimizedStaticFilesStorage'
# Optional: configure build profile path
REQUIRE_BUILD_PROFILE = 'path/to/build.js'