django-utils v0.3.0 documentation

This Page

Helpers

This module contains a few helper functions that are frequently copy/pasted between projects. Kind of a mixed bag.

djutils.utils.helpers.load_class(path)

dynamically load a class given a string of the format “package.Class”

BackendClass = load_class('djutils.queue.backends.database.DatabaseBackend')
djutils.utils.helpers.generic_autodiscover(module_name)

I have copy/pasted this code too many times...Dynamically autodiscover a particular module_name in a django project’s INSTALLED_APPS directories, a-la django admin’s autodiscover() method.

Usage:

generic_autodiscover('commands') # find all commands.py and load 'em