Skip to content

Instantly share code, notes, and snippets.

@estebistec
Created October 28, 2012 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save estebistec/3967289 to your computer and use it in GitHub Desktop.
Save estebistec/3967289 to your computer and use it in GitHub Desktop.
Automatically detect apps with less folders to setup lessc include-path
def get_less_static_dirs():
"""get static-directory paths for apps that have less files
Assumptions:
* You want any LESS files from apps in INSTALLED_APPS
* You don't have LESS files in any extra folders in STATIC_DIRS (maybe I should fix that... always thought static_dirs was dumb)
"""
app_modules = [import_module(app) for app in INSTALLED_APPS]
maybe_less_static_dirs = [
# For Django apps, __file__ should always be the path to __init__.pyc
'{0}/static'.format(os.path.dirname(app_module.__file__))
for app_module in app_modules
]
return [
path for path in maybe_less_static_dirs
if os.path.isdir(os.path.join(path, 'less'))
]
PIPELINE_LESS_ARGUMENTS = '--include-path=' + ':'.join(get_less_static_dirs())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment