Browse files

Add ASSETS_MODULES Django setting.

Deprecated the auto-load of a project-level "assets.py", which doesn't work
well with Django 1.4 in particular.

Closes #113.
  • Loading branch information...
1 parent 57cee4c commit 596e969964e83aaaa8dac6b75965121d1e8eae05 @miracle2k committed Mar 11, 2012
Showing with 21 additions and 6 deletions.
  1. +14 −0 docs/django/settings.rst
  2. +4 −0 docs/upgrading.rst
  3. +3 −6 src/django_assets/env.py
View
14 docs/django/settings.rst
@@ -46,3 +46,17 @@ in your project's global settings.
using with Jinja 2, using which it should be possible to construct a
Jinja 2 environment which can parse your templates. For more information,
see :doc:`jinja2`.
+
+.. _django-setting-modules:
+
+.. data:: ASSETS_MODULES
+ :noindex:
+
+ ``django-assets`` will automatically look for ``assets.py`` files in each
+ application, where you can register your bundles. If you want additional
+ modules to be loaded, you can define this setting. It expects a list of
+ importable modules::
+
+ ASSETS_MODULES = [
+ 'myproject.assets'
+ ]
View
4 docs/upgrading.rst
@@ -59,6 +59,10 @@ Other changes:
filter and have not explicitly given it a name, you need to do this now if
you want to register the filter globally.
+- ``django_assets`` no longer tries to load a global ``assets.py`` module (it
+ will still find bundles defined in application-level ``assets.py`` files). If
+ you want to define bundles in other modules, you now need to list those
+ explicitly in the :ref:`ASSETS_MODULES <django-setting-modules>` setting.
In 0.6
~~~~~~
View
9 src/django_assets/env.py
@@ -201,11 +201,8 @@ def autoload():
#if options.get('verbosity') > 1:
# print "assets module loaded"
- # Look for an assets.py at the project level
- try:
- import_module('assets')
- except ImportError:
- # not found, just ignore
- pass
+ # Load additional modules.
+ for module in getattr(settings, 'ASSETS_MODULES', []):
+ import_module("%s" % module)
_ASSETS_LOADED = True

0 comments on commit 596e969

Please sign in to comment.