Skip to content

Commit

Permalink
Add ASSETS_MODULES Django setting.
Browse files Browse the repository at this point in the history
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
miracle2k committed Mar 11, 2012
1 parent 57cee4c commit 596e969
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
14 changes: 14 additions & 0 deletions docs/django/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]
4 changes: 4 additions & 0 deletions docs/upgrading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
~~~~~~
Expand Down
9 changes: 3 additions & 6 deletions src/django_assets/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.