def import_by_path(dotted_path, error_prefix='<STR_LIT>'):
try:<EOL><INDENT>module_path, class_name = dotted_path.rsplit('<STR_LIT:.>', <NUM_LIT:1>)<EOL><DEDENT>except ValueError:<EOL><INDENT>raise ImproperlyConfigured("<STR_LIT>" % (<EOL>error_prefix, dotted_path))<EOL><DEDENT>try:<EOL><INDENT>module = import_module(module_path)<EOL><DEDENT>except ImportError as e:<EOL><INDENT>msg = '<STR_LIT>' % (<EOL>error_prefix, module_path, e)<EOL>raise ImproperlyConfigured(msg)<EOL><DEDENT>try:<EOL><INDENT>attr = getattr(module, class_name)<EOL><DEDENT>except AttributeError:<EOL><INDENT>raise ImproperlyConfigured('<STR_LIT>' %<EOL>(error_prefix, module_path, class_name))<EOL><DEDENT>return attr<EOL>
Import a dotted module path and return the attribute/class designated by
the last name in the path. Raise ImproperlyConfigured if something goes
wrong.

.. warning::
    .. deprecated:: Django 1.6

    Function :py:func:`django.utils.module_loading.import_by_path` has
    been added in Django 1.6.

:param dotted_path: Path to imported attribute or class
:type dotted_path: str

:return: imported attribute or class